Skip to content

Instantly share code, notes, and snippets.

@msaroufim
Created October 27, 2019 22:10
Show Gist options
  • Save msaroufim/794da1c039d02f4e02a8aedff925a44f to your computer and use it in GitHub Desktop.
Save msaroufim/794da1c039d02f4e02a8aedff925a44f to your computer and use it in GitHub Desktop.
# Full example here https://github.com/JuliaOpt/JuMP.jl/blob/master/examples/cannery.jl
@variable(cannery, ship[1:num_plants, 1:num_markets] >= 0)
# Ship no more than plant capacity
@constraint(cannery, capacity_con[i in 1:num_plants],
sum(ship[i,j] for j in 1:num_markets) <= capacity[i]
)
# Ship at least market demand
@constraint(cannery, demand_con[j in 1:num_markets],
sum(ship[i,j] for i in 1:num_plants) >= demand[j]
)
# Minimize transporatation cost
@objective(cannery, Min, sum(distance[i, j] * freight * ship[i, j]
for i in 1:num_plants, j in 1:num_markets)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment