Transportation problem: Difference between revisions
Content added Content deleted
(→{{header|R}}: fix double output line) |
(→{{header|Julia}}: swap optimizers: GLPK for Ipopt (produces integer solutions)) |
||
Line 2,496: | Line 2,496: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Code taken from [https://github.com/dylanomics/transportation_problem here] using [https://jump.dev/JuMP.jl/stable/ JuMP]. |
Code taken from [https://github.com/dylanomics/transportation_problem here] using [https://jump.dev/JuMP.jl/stable/ JuMP]. |
||
<lang julia>using JuMP, |
<lang julia>using JuMP, GLPK |
||
# cost vector |
# cost vector |
||
Line 2,512: | Line 2,512: | ||
# construct model |
# construct model |
||
model = Model( |
model = Model(GLPK.Optimizer) |
||
@variable(model, x[i=1:N] >= 0, base_name="traded quantities") |
@variable(model, x[i=1:N] >= 0, base_name="traded quantities") |
||
cost_fn = @expression(model, c'*x) # cost function |
cost_fn = @expression(model, c'*x) # cost function |
||
Line 2,531: | Line 2,531: | ||
{{out}} |
{{out}} |
||
<pre>solution vector of quantities = [20. |
<pre>solution vector of quantities = [20.0, 0.0, 5.0, 0.0, 30.0, 5.0] |
||
minimum total cost = |
minimum total cost = 180.0</pre> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |