Consider a company that operates a fleet of cargo ships. The company wants to optimize its shipping routes and cargo loadings to maximize profits over a planning horizon of T time periods. Each time period t corresponds to a specific month, and the company can choose the routes and cargo loadings for each ship in each time period.
The company faces uncertainty in the form of unpredictable demand for cargo shipping and varying fuel prices. Specifically, the demand for cargo shipping and the fuel prices are modeled as random variables that are drawn from known probability distributions at the beginning of each time period.
The company's objective is to maximize its expected profits over the planning horizon, subject to a number of constraints. These constraints include:
Capacity constraints: Each ship has a maximum cargo capacity, and the total cargo loaded on a ship in any time period must not exceed this capacity.
Demand constraints: The total demand for cargo shipping in each time period must be satisfied.
Budget constraints: The company has a fixed budget for fuel costs in each time period, and the total fuel costs for all ships in that time period must not exceed this budget.
Would be the following code suitable?
using JuMP, Clp
# Set the number of time periods (T), ships (S), and cargo destinations (D)
T = 12
S = 10
D = 20
# Set the maximum cargo capacity of each ship
max_capacity = [5000, 6000, 4000, 4500, 5000, 5500, 4500, 5000, 5500, 4000]
# Set the demand for cargo shipping in each time period and destination
demand = rand(T, D)
# Set the fuel price in each time period
fuel_price = rand(T)
# Set the fixed budget for fuel costs in each time period
fuel_budget = rand(T)
# Create the optimization model
m = Model(solver=ClpSolver())
# Decision variables
@variable(m, route[t in 1:T, s in 1:S, d in 1:D], Bin) # shipping route for each time period, ship, and destination
@variable(m, cargo[t in 1:T, s in 1:S, d in 1:D]) # cargo loading for each time period, ship, and destination
# Constraints
@constraint(m, capacity[t in 1:T, s in 1:S], sum(cargo[t, s, d] for d in 1:D) <= max_capacity[s]) # capacity constraints
@constraint(m, demand[t in 1:T, d in 1:D], sum(cargo[t, s, d] for s in 1:S) == demand[t, d]) # demand constraints
@constraint(m, budget[t in 1:T], sum(fuel_price[t] * route[t, s, d] * cargo[t, s, d] for s in 1:S, d in 1:D) <= fuel_budget[t]) # budget constraints
# Objective function
@objective(m, Max, sum(route[t, s, d] * cargo[t, s, d] * (1 - fuel_price[t]) for t in 1:T, s in 1:S, d in 1:D)) # maximize expected profits
# Solve the optimization problem
solve(m)
# Print the optimal shipping routes and cargo loadings
println("Optimal shipping routes:")
println(route)
println("Optimal cargo loadings:")
println(cargo)
Consider a company that operates a fleet of cargo ships. The company wants to optimize its shipping routes and cargo loadings to maximize profits over a planning horizon of T time periods. Each time period t corresponds to a specific month, and the company can choose the routes and cargo loadings for each ship in each time period.
The company faces uncertainty in the form of unpredictable demand for cargo shipping and varying fuel prices. Specifically, the demand for cargo shipping and the fuel prices are modeled as random variables that are drawn from known probability distributions at the beginning of each time period.
The company's objective is to maximize its expected profits over the planning horizon, subject to a number of constraints. These constraints include:
Capacity constraints: Each ship has a maximum cargo capacity, and the total cargo loaded on a ship in any time period must not exceed this capacity. Demand constraints: The total demand for cargo shipping in each time period must be satisfied. Budget constraints: The company has a fixed budget for fuel costs in each time period, and the total fuel costs for all ships in that time period must not exceed this budget.
Would be the following code suitable?
Thanks Bernardo. Cheers @bfpc