Week1: Operations Research¶
Pluto上でJuMPを用いて以下の線型計画問題(Linear Programming Problem)を解いた。
問題¶
以下の制約
\[s \ge 0, c \ge 0\]
\[12s + 8c \le 480\]
\[2s + c \le 120\]
\[\frac{1}{2}s + 2c \le 40\]
のもとで
\[max\,\,4s + 6c\]
となる\(s,c\)を求める。
コード¶
begin
model = Model(HiGHS.Optimizer)
@variable(model, s >= 0)
@variable(model, c >= 0)
@objective(model, Max, 4s + 6c)
@constraint(model, conditions1, 2s + c <= 120)
@constraint(model, conditions2, 0.5s + 2c <= 40)
@constraint(model, conditions3, 12s + 8c <= 480)
end
出力
Max 4 s + 6 c
Subject to
conditions1 : 2 s + c ≤ 120
conditions2 : 0.5 s + 2 c ≤ 40
conditions3 : 12 s + 8 c ≤ 480
s ≥ 0
c ≥ 0
出力
Running HiGHS 1.15.1 (git hash: 04024d701f): Copyright (c) 2026 under MIT licence terms
Includes third-party software components, see THIRD_PARTY_NOTICES.md for full details
Using BLAS: libblastrampoline
LP has 3 rows; 2 cols; 6 nonzeros
Coefficient ranges:
Matrix [5e-01, 1e+01]
Cost [4e+00, 6e+00]
Bound [0e+00, 0e+00]
RHS [4e+01, 5e+02]
Presolving model
3 rows, 2 cols, 6 nonzeros 0s
2 rows, 2 cols, 4 nonzeros 0s
Presolve reductions: rows 2(-1); columns 2(-0); nonzeros 4(-2)
Solving the presolved LP
Using dual simplex solver
Iteration Objective Infeasibilities num(sum)
0 -3.4999957370e+00 Ph1: 2(5); Du: 2(3.5) 0.0s
2 -2.0000000000e+02 Pr: 0(0) 0.0s
Performed postsolve
Solving the original LP from the solution after postsolve
Model status : Optimal
Simplex iterations: 2
Objective value : 2.0000000000e+02
P-D objective error : 0.0000000000e+00
HiGHS run time : 0.02
出力
グラフ¶
この制約のもとで、sとcについての領域のグラフをdesmosを用いて描いた。
