Main Content

混合整数線形計画法の基礎: 問題ベース

この例では、混合整数線形問題を解く方法を説明します。この例は複雑ではありませんが、問題ベースのアプローチを使用して問題を定式化する一般的な手順を示しています。この例を示すビデオについては、Solve a Mixed-Integer Linear Programming Problem using Optimization Modeling を参照してください。

この問題に対するソルバーベースのアプローチについては、混合整数線形計画法の基礎: ソルバーベースを参照してください。

問題の説明

さまざまな化学組成の鋼鉄を融合して、特定の化学組成の 25 トンの鋼鉄を精製するものとします。精製された製品には、重量で炭素 5% とモリブデン 5% (つまり、炭素が 25 トン*5% = 1.25 トン、モリブデンが 1.25 トン) が含まれている必要があります。目的は鋼鉄の融合コストを最小化することです。

この問題は、Carl-Henrik Westerberg、Bengt Bjorklund および Eskil Hultman "An Application of Mixed Integer Programming in a Swedish Steel Mill" Interfaces February 1977 Vol. 7, No. 2 pp. 39–43 から引用されたものです。これらの要旨は https://doi.org/10.1287/inte.7.2.39 で参照できます。

このために 4 つの鋼鉄のインゴットを購入できます。各インゴットの 1 つしか利用できません。

IngotWeightinTons%Carbon%MolybdenumCostTon1553$3502343$3303454$3104634$280

3 つのグレードの合金および 1 つのグレードの鋼鉄くずを購入できます。合金と鋼鉄くずは分割して購入できます。

Alloy%Carbon%MolybdenumCostTon186$500277$450368$400Scrap39$100

問題の定式化

問題を定式化するには、まず制御変数を決定します。変数 ingots(1) = 1 を取るとインゴット "1" の購入を意味し、ingots(1) = 0 を取るとインゴットを購入しないことを意味します。同様に、変数 ingots(2)ingots(4) は、インゴット 24 を購入するかどうかを示す 2 値変数です。

変数 alloys(1)alloys(3) は購入する合金 12、および 3 のトン単位の量です。scrap は購入する鋼鉄くずの量を示します。

steelprob = optimproblem;
ingots = optimvar('ingots',4,'Type','integer','LowerBound',0,'UpperBound',1);
alloys = optimvar('alloys',3,'LowerBound',0);
scrap = optimvar('scrap','LowerBound',0);

変数と関連付けられたコストの式を作成します。

weightIngots = [5,3,4,6];
costIngots = weightIngots.*[350,330,310,280];
costAlloys = [500,450,400];
costScrap = 100;
cost = costIngots*ingots + costAlloys*alloys + costScrap*scrap;

問題に目的関数としてコストを含めます。

steelprob.Objective = cost;

この問題には 3 つの等式制約があります。最初の制約は総重量が 25 トンであることです。鋼鉄の重量を計算します。

totalWeight = weightIngots*ingots + sum(alloys) + scrap;

2 番目の制約は炭素の重量が 25 トンの 5% (1.25 トン) であることです。鋼鉄内の炭素の重量を計算します。

carbonIngots = [5,4,5,3]/100;
carbonAlloys = [8,7,6]/100;
carbonScrap = 3/100;
totalCarbon = (weightIngots.*carbonIngots)*ingots + carbonAlloys*alloys + carbonScrap*scrap;

3 番目の制約はモリブデンの重量が 1.25 トンであることです。鋼鉄内のモリブデンの重量を計算します。

molybIngots = [3,3,4,4]/100;
molybAlloys = [6,7,8]/100;
molybScrap = 9/100;
totalMolyb = (weightIngots.*molybIngots)*ingots + molybAlloys*alloys + molybScrap*scrap;

制約を問題に含めます。

steelprob.Constraints.conswt = totalWeight == 25;
steelprob.Constraints.conscarb = totalCarbon == 1.25;
steelprob.Constraints.consmolyb = totalMolyb == 1.25;

問題を解く

すべての入力を指定したら、ソルバーを呼び出します。

[sol,fval] = solve(steelprob);
Solving problem using intlinprog.
Running HiGHS 1.6.0: Copyright (c) 2023 HiGHS under MIT licence terms
Presolving model
3 rows, 8 cols, 24 nonzeros
3 rows, 8 cols, 18 nonzeros

Solving MIP model with:
   3 rows
   8 cols (4 binary, 0 integer, 0 implied int., 4 continuous)
   18 nonzeros

        Nodes      |    B&B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work      
     Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time

         0       0         0   0.00%   0               inf                  inf        0      0      0         0     0.0s
         0       0         0   0.00%   8125.6          inf                  inf        0      0      0         4     0.0s
 R       0       0         0   0.00%   8495            8495               0.00%        5      0      0         5     0.0s

Solving report
  Status            Optimal
  Primal bound      8495
  Dual bound        8495
  Gap               0% (tolerance: 0.01%)
  Solution status   feasible
                    8495 (objective)
                    0 (bound viol.)
                    0 (int. viol.)
                    0 (row viol.)
  Timing            0.01 (total)
                    0.00 (presolve)
                    0.00 (postsolve)
  Nodes             1
  LP iterations     5 (total)
                    0 (strong br.)
                    1 (separation)
                    0 (heuristics)

Optimal solution found.

Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 1e-06. The intcon variables are integer within tolerance, options.ConstraintTolerance = 1e-06.

解を表示します。

sol.ingots
ans = 4×1

     1
     1
     0
     1

sol.alloys
ans = 3×1

    7.2500
         0
    0.2500

sol.scrap
ans = 3.5000
fval
fval = 8495

最適購入コストは $8,495 です。インゴット 124 を購入し、3 を購入しません。合金 1 を 7.25 トン、合金 3 を 0.25 トン、鋼鉄くずを 3.5 トン購入します。

関連するトピック