This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ | |
config( | |
materialized='incremental' | |
) | |
}} | |
with orders as ( | |
select * from {{ ref('stg__orders') }} | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Encrypts or Decrypts messages. For encryption: | |
python cipherize.py --message=test --action=encrypt | |
or | |
python3 cipherize.py --filepath /path/to/file --action encrypt | |
Decryption: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.mark.django_db | |
def test_data_2(): | |
""" | |
Force overbooking of ships. | |
""" | |
name = 'test2' | |
f = Files.objects.create(name=name) | |
f.save() | |
demand_data = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def optimize(data_models, train_limit, ob_cost_factor=2, container_cost_factor=10): | |
results = {} | |
containers = data_models['containers'] | |
shippers = data_models['shippers'] | |
orig_ports = data_models['orig_port'] | |
transp = data_models['transp'] | |
transp_train_map = data_models['transp_train_map'] | |
shipper_trade_spaces = data_models['shipper_trade_spaces'] | |
overbooking_spaces = shipper_trade_spaces.matrix | |
dest_shipper_map = data_models['dest_shipper_map'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cvxpy as cx | |
# Begin with variables | |
x_shippers = cx.Variable((4, 2), boolean=True, name='shippers') | |
x_transports = cx.Variable((4, 2), boolean=True, name='transports') | |
x_docks = cx.Variable((4, 2), boolean=True, name='docks') | |
# 'y' represents variables that are built by introducing an AND conjunction between | |
# 2 other variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cvxpy as cx | |
# Begin with the variables that describe the problem | |
x_shippers = cx.Variable((4, 2), boolean=True, name='shippers') | |
x_transports = cx.Variable((4, 2), boolean=True, name='transports') | |
# Data that helps implement the model | |
containers = np.array([[200, 0], [300, 1], [400, 0], [500, 1]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cvxpy as cx | |
# First the data that sets the problem | |
container_costs = np.array([200, 300, 400, 500]) | |
shippers_costs = np.array([100, 130]) | |
shippers_spaces = np.array([2, 1]) | |
# Main variable to be optimized | |
x_shippers = cx.Variable((4, 2), boolean=True, name='shippers') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trade | Shipper | 1 | 2 | 3 | 4 | ... | 52 | |
---|---|---|---|---|---|---|---|---|
North Europe | Shipper 0 | 7 | 7 | 6 | 5 | ... | 7 | |
North America | Shipper 1 | 8 | 8 | 8 | 9 | ... | 6 | |
Far East | Shipper 2 | 6 | 6 | 7 | 8 | ... | 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Factory | Trade | Destine Port | Shipper | Modal | Origin Port | Transport | Road Freight | Shipper Freight | |
---|---|---|---|---|---|---|---|---|---|
factory 0 | Far East | Hong Kong | Shipper 0 | Road | Santos | Third Party | 6000 | 8000 | |
factory 1 | Mediterranean | Barcelona | Shipper 1 | Train | Santos | Private | 5000 | 9000 | |
factory 2 | North America | Seattle | Shipper 3 | Road | Santos | Third Party | 9000 | 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Container ID | Factory | Destination | Worth | Shipper | Transportation | Origin | |
---|---|---|---|---|---|---|---|
0 | Factory 0 | Hong Kong | 1000 | ? | ? | ? | |
1 | Factory 1 | Barcelona 1 | 1200 | ? | ? | ? | |
2 | Factory 0 | Seattle 2 | 1300 | ? | ? | ? |
NewerOlder