メインコンテンツ

このページは機械翻訳を使用して翻訳されました。最新版の英語を参照するには、ここをクリックします。

遺伝的アルゴリズムを用いた混合整数エンジニアリング設計問題の解決、問題ベース

この例では、Global Optimization Toolbox の遺伝的アルゴリズム (ga) ソルバーを使用して、混合整数エンジニアリング設計問題を解決する方法を示します。この例では、問題ベースのアプローチを使用します。ソルバーベースのアプローチを使用するバージョンについては、遺伝的アルゴリズムを用いた混合整数エンジニアリング設計問題の解決 を参照してください。

この例で示す問題は、段状の片持ち梁の設計に関するものです。特に、梁は規定の端部荷重に耐えることができなければなりません。最適化の問題は、さまざまなエンジニアリング設計の制約に従って梁の体積を最小化することです。

この問題はThanedarとVanderplaats [1]で説明されています。

段付き片持ち梁の設計問題

次の図に示すように、段付きの片持ち梁は一方の端で支えられ、自由端に荷重がかかります。梁は、サポートから一定の距離 L で指定された荷重 P を支えることができなければなりません。梁の設計者は、各ステップまたはセクションの幅 (bi) と高さ (hi) を変更できます。カンチレバーの各セクションの長さは同じで、l=L1 です。

ビームの体積

梁の体積 V は、個体のセクションの体積の合計です。

V=l(b1h1+b2h2+b3h3+b4h4+b5h5).

設計上の制約:曲げ応力

座標の中心が梁の自由端の断面の中心にある、単一の片持ち梁を考えます。梁の点(x,y,z)における曲げ応力は次式で与えられる。

σb=M(x)y/I,

ここで、M(x)x における曲げモーメント、x は端部荷重からの距離、I は梁の面積モーメントです。

図に示す段付き片持ち梁では、梁の各セクションの最大モーメントは PDi です。ここで、Di は梁の各セクションの端部荷重 P からの最大距離です。したがって、梁σii番目のセクションの最大応力は次のように表される。

σi=PDi(hi/2)/Ii,

最大応力は梁の端で発生します(y=hi/2)。梁のi番目の断面の断面2次モーメントは次のように与えられる。

Ii=bihi3/12.

この式をσiの式に代入すると、

σi=6PDi/bihi2.

カンチレバーの各部分の曲げ応力は、最大許容応力 σmax を超えてはなりません。したがって、5 つの曲げ応力制約 (カンチレバーの各ステップに 1 つ) は次のようになります。

6Plb5h52σmax

6P(2l)b4h42σmax

6P(3l)b3h32σmax

6P(4l)b2h22σmax

6P(5l)b1h12σmax

設計上の制約:端部たわみ

カスチリアーノの第二定理を使って片持ち梁の端のたわみを計算することができます。

δ=UP,

ここで、δ は梁のたわみ、U は適用された力 P により梁に蓄えられたエネルギーです。

片持ち梁に蓄えられたエネルギーは次のように表される。

U=0LM2/2EIdx,

ここで、Mx における適用された力のモーメントです。

片持ち梁のM=Pxを考えると、前述の式は次のように書けます。

U=P2/2E0l[(x+4l)2/I1+(x+3l)2/I2+(x+2l)2/I3+(x+l)2/I4+x2/I5]dx,

ここで、In はカンチレバーの n 番目の部分の面積モーメントです。積分を評価するとUの式が得られる。

U=(P2/2)(l3/3E)(61/I1+37/I2+19/I3+7/I4+1/I5).

カスティリアーノの定理を適用すると、梁の端部のたわみは次のように表される。

δ=Pl3/3E(61/I1+37/I2+19/I3+7/I4+1/I5).

片持ち梁の端部たわみδは、最大許容たわみδmaxより小さくなければなりません。これにより、制約が与えられます。

Pl3/3E(61/I1+37/I2+19/I3+7/I4+1/I5)δmax.

設計上の制約:アスペクト比

カンチレバーの各ステップのアスペクト比は、最大許容アスペクト比 amax を超えてはなりません。つまり、

hi/biamax (i=1,...,5)

設計上の制約:境界と整数制約

ビームの最初のステップは、最も近いセンチメートル単位でのみ機械加工できます。つまり、b1h1 は整数である必要があります。残りの変数は連続的です。変数の境界は次のとおりです。

1b15

30h165

2.4b2,b33.1

45h2,h360

1b4,b55

30h4,h565

この問題の設計パラメーター

この例の問題では、梁がサポートする必要がある端部荷重は P=50000N です。

梁の長さと最大端部たわみは次のとおりです。

  • ビーム全長、L=500cm

  • 梁の個体のセクションの長さ、l=L1=100cm

  • 最大梁端たわみ、δmax=2.7cm

梁の各ステップで許容される最大応力は σmax=14000N/cm2 です。

梁の各段のヤング率は E=2×107N/cm2 です。

問題ベースの設定

この問題の最適化変数を作成します。梁の最初のセクションの幅と高さの変数は整数型なので、連続する他の 4 つの変数とは別に作成する必要があります。

b1 = optimvar("b1","Type","integer","LowerBound",1,"UpperBound",5);
h1 = optimvar("h1","Type","integer","LowerBound",30,"UpperBound",65);
bc = optimvar("bc",4,"LowerBound",[2.4 2.4 1 1],"UpperBound",[3.1 3.1 5 5]);
hc = optimvar("hc",4,"LowerBound",[45 45 30 30],"UpperBound",[60 60 65 65]);

便宜上、高さと幅の変数を単一の変数に入れます。これらの変数を使用して、目的と制約を簡単に表現できます。

h = [h1;hc];
b = [b1;bc];

梁の体積を目的関数として最適化問題を作成します。梁の各ステップ (またはセクション) の長さは L1=100 cm です: 体積 = L1hiwi

L_1 = 100; % Length of each step of the cantilever
prob = optimproblem("Objective",L_1*dot(h,b));

応力に対する制約を作成します。

P = 50000; % End load
E = 2e7; % Young's modulus in N/cm^2
deltaMax = 2.7; % Maximum end deflection
sigmaMax = 14000; % Maximum stress in each section of the beam
aMax = 20; % Maximum aspect ratio in each section of the beam

stress = 6*P*L_1./(b.*(h.^2));
stepnum = (5:-1:1)';
stress = stress.*stepnum;
prob.Constraints.stress = stress <= sigmaMax;

たわみに対する制約を作成します。

deflectionMultiplier = (P*L_1^3/E)*[244 148 76 28 4];
bh3 = 1./(b.*(h.^3));
prob.Constraints.deflection = deflectionMultiplier*bh3 <= deltaMax;

アスペクト比の制約を作成します。

prob.Constraints.aspect = h <= aMax*b;

問題の設定を確認します。

show(prob)
  OptimizationProblem : 

	Solve for:
       b1, bc, h1, hc
	where:
       b1, h1 integer
	minimize :
       100*h1*b1 + 100*hc(1)*bc(1) + 100*hc(2)*bc(2) + 100*hc(3)*bc(3) + 100*hc(4)*bc(4)


	subject to stress:
       arg_LHS <= arg_RHS

       where:

             arg2 = zeros(5, 1);
             arg1 = zeros(5, 1);
             arg1(1) = h1;
             arg1(2:5) = hc;
             arg2(1) = b1;
             arg2(2:5) = bc;
             arg_LHS = ((30000000 ./ (arg2(:) .* arg1(:).^2)) .* extraParams{1});
             arg2 = 14000;
             arg1 = arg2(ones(1,5));
             arg_RHS = arg1(:);

       extraParams

	subject to deflection:
       arg_LHS <= 2.7

       where:

             arg2 = zeros(5, 1);
             arg1 = zeros(5, 1);
             arg1(1) = h1;
             arg1(2:5) = hc;
             arg2(1) = b1;
             arg2(2:5) = bc;
             arg_LHS = (extraParams{1} * (1 ./ (arg2(:) .* arg1(:).^3)));

       extraParams

	subject to aspect:
       -20*b1 + h1 <= 0
       -20*bc(1) + hc(1) <= 0
       -20*bc(2) + hc(2) <= 0
       -20*bc(3) + hc(3) <= 0
       -20*bc(4) + hc(4) <= 0

	variable bounds:
       1 <= b1 <= 5

       2.4 <= bc(1) <= 3.1
       2.4 <= bc(2) <= 3.1
         1 <= bc(3) <=   5
         1 <= bc(4) <=   5

       30 <= h1 <= 65

       45 <= hc(1) <= 60
       45 <= hc(2) <= 60
       30 <= hc(3) <= 65
       30 <= hc(4) <= 65

問題を解く

オプションを設定して、中程度の母集団サイズ 150、中程度の最大世代数 400、デフォルトのエリート数よりわずかに大きい 10、小さな関数許容値 1e-8、反復中の関数値を表示するプロット関数を使用します。

opts = optimoptions(@ga, ...
                    'PopulationSize', 150, ...
                    'MaxGenerations', 400, ...
                    'EliteCount', 10, ...
                    'FunctionTolerance', 1e-8, ...
                    'PlotFcn', @gaplotbestf);

ga ソルバーとオプションを指定して問題を解きます。

rng default % For reproducibility
[sol,fval,exitflag] = solve(prob,"Solver","ga","Options",opts)
Solving problem using ga.

Figure Genetic Algorithm contains an axes object. The axes object with title Best: 63803.7 Mean: 83810.3, xlabel Generation, ylabel Penalty value contains 2 objects of type scatter. These objects represent Best penalty value, Mean penalty value.

ga stopped because the average change in the penalty function value is less than options.FunctionTolerance and 
the constraint violation is less than options.ConstraintTolerance.
sol = struct with fields:
    b1: 3
    bc: [4×1 double]
    h1: 60
    hc: [4×1 double]

fval = 
6.3804e+04
exitflag = 
    SolverConvergedSuccessfully

ソリューション変数とその境界を表示します。

widths = [sol.b1;sol.bc];
heights = [sol.h1;sol.hc];
widthbounds = [b1.LowerBound b1.UpperBound;
    bc.LowerBound bc.UpperBound];
heightbounds = [h1.LowerBound h1.UpperBound;
    hc.LowerBound hc.UpperBound];
T = table(widths,heights,widthbounds,heightbounds,...
    'VariableNames',["Width" "Height" "Width Bounds" "Height Bounds"])
T=5×4 table
    Width     Height    Width Bounds    Height Bounds
    ______    ______    ____________    _____________

         3        60       1      5       30    65   
    2.9063    54.983     2.4    3.1       45    60   
    2.5805    51.609     2.4    3.1       45    60   
    2.2785    45.565       1      5       30    65   
    1.7502    34.991       1      5       30    65   

解はどの境界にも存在しません。最初のソリューション変数は、指定されたとおり整数値になります。

離散非整数変数制約を追加する

エンジニアが、カンチレバーの 2 段目と 3 段目では、幅と高さを標準セットからのみ選択できることを知ったとします。この制約を追加すると、問題は[1]で解決された問題と同一になります。

まず、最適化に追加する追加の制約を定義します。

  • 梁の2段目と3段目の幅は、[2.4、2.6、2.8、3.1]cmから選択する必要があります。

  • 梁の2段目と3段目の高さは、[45、50、55、60]cmから選択する必要があります。

この問題を解決するには、変数 wc(1)wc(2)hc(1)、および hc(2) を離散変数として指定する必要があります。理想的には、離散値として S(xj) を使用します。ここで、S は許容される値のセットを表し、xj は問題の変数を表します。ただし、最適化変数をインデックスとして使用することはできません。この問題は、fcn2optimexpr を呼び出すことによって回避できます。

widthlist = [2.4,2.6,2.8,3.1];
heightlist = [45 50 55 60];
b23 = optimvar("w23",2,"Type","integer",...
    "LowerBound",1,"UpperBound",length(widthlist));
h23 = optimvar("h23",2,"Type","integer",...
    "LowerBound",1,"UpperBound",length(heightlist));
b45 = optimvar("b45",2,"LowerBound",1,"UpperBound",5);
h45 = optimvar("h45",2,"LowerBound",30,"UpperBound",65);
% Preferred syntax is we = [widthlist(b23(1));widthlist(b23(2))];
% However, this syntax is illegal.
% Instead call fcn2optimexpr.
we = fcn2optimexpr(@(x)[widthlist(x(1));widthlist(x(2))],b23);
he = fcn2optimexpr(@(x)[heightlist(x(1));heightlist(x(2))],h23);

先ほどと同じように、変数を表す式 bh を作成します。

b = [b1;we;b45];
h = [h1;he;h45];

問題の残りの定式化は前と同じです。

prob2 = optimproblem("Objective",L_1*dot(h,b));

応力に対する制約を作成します。

stress = 6*P*L_1./(b.*(h.^2));
stepnum = (5:-1:1)';
stress = stress.*stepnum;
prob2.Constraints.stress = stress <= sigmaMax;

たわみに対する制約を作成します。

deflectionMultiplier = (P*L_1^3/E)*[244 148 76 28 4];
bh3 = 1./(b.*(h.^3));
prob2.Constraints.deflection = deflectionMultiplier*bh3 <= deltaMax;

アスペクト比の制約を作成します。

prob2.Constraints.aspect = h <= aMax*b;

問題の設定を確認します。

show(prob2)
  OptimizationProblem : 

	Solve for:
       b1, b45, h1, h23, h45, w23
	where:
       b1, h1, h23, w23 integer
	minimize :
       (100 .* (arg2(:).' * arg4(:)))

       where:

           arg4 = zeros(5, 1);
           arg2 = zeros(5, 1);
           anonymousFunction2 = @(x)[heightlist(x(1));heightlist(x(2))];
           arg1 = anonymousFunction2(h23);
           arg2(1) = h1;
           arg2(2:3) = arg1;
           arg2(4:5) = h45;
           anonymousFunction1 = @(x)[widthlist(x(1));widthlist(x(2))];
           arg3 = anonymousFunction1(w23);
           arg4(1) = b1;
           arg4(2:3) = arg3;
           arg4(4:5) = b45;


	subject to stress:
       arg_LHS <= arg_RHS

       where:

             arg4 = zeros(5, 1);
             arg2 = zeros(5, 1);
             anonymousFunction2 = @(x)[heightlist(x(1));heightlist(x(2))];
             arg1 = anonymousFunction2(h23);
             arg2(1) = h1;
             arg2(2:3) = arg1;
             arg2(4:5) = h45;
             anonymousFunction1 = @(x)[widthlist(x(1));widthlist(x(2))];
             arg3 = anonymousFunction1(w23);
             arg4(1) = b1;
             arg4(2:3) = arg3;
             arg4(4:5) = b45;
             arg_LHS = ((30000000 ./ (arg4(:) .* arg2(:).^2)) .* extraParams{1});
             arg2 = 14000;
             arg1 = arg2(ones(1,5));
             arg_RHS = arg1(:);

       extraParams

	subject to deflection:
       arg_LHS <= 2.7

       where:

             arg4 = zeros(5, 1);
             arg2 = zeros(5, 1);
             anonymousFunction2 = @(x)[heightlist(x(1));heightlist(x(2))];
             arg1 = anonymousFunction2(h23);
             arg2(1) = h1;
             arg2(2:3) = arg1;
             arg2(4:5) = h45;
             anonymousFunction1 = @(x)[widthlist(x(1));widthlist(x(2))];
             arg3 = anonymousFunction1(w23);
             arg4(1) = b1;
             arg4(2:3) = arg3;
             arg4(4:5) = b45;
             arg_LHS = (extraParams{1} * (1 ./ (arg4(:) .* arg2(:).^3)));

       extraParams

	subject to aspect:
       arg_LHS <= arg_RHS

       where:

             arg1 = zeros(5, 1);
             arg1(1) = h1;
             anonymousFunction2 = @(x)[heightlist(x(1));heightlist(x(2))];
             arg2 = anonymousFunction2(h23);
             arg1(2:3) = arg2;
             arg1(4:5) = h45;
             arg_LHS = arg1(:);
             arg2 = zeros(5, 1);
             anonymousFunction1 = @(x)[widthlist(x(1));widthlist(x(2))];
             arg1 = anonymousFunction1(w23);
             arg2(1) = b1;
             arg2(2:3) = arg1;
             arg2(4:5) = b45;
             arg_RHS = (20 .* arg2(:));

	variable bounds:
       1 <= b1 <= 5

       1 <= b45(1) <= 5
       1 <= b45(2) <= 5

       30 <= h1 <= 65

       1 <= h23(1) <= 4
       1 <= h23(2) <= 4

       30 <= h45(1) <= 65
       30 <= h45(2) <= 65

       1 <= w23(1) <= 4
       1 <= w23(2) <= 4

離散変数制約の問題を解く

ga ソルバーとオプションを指定して問題を解きます。

rng default % For reproducibility
[sol2,fval2,exitflag2] = solve(prob2,"Solver","ga","Options",opts)
Solving problem using ga.

Figure Genetic Algorithm contains an axes object. The axes object with title Best: 64803.2 Mean: 69025.3, xlabel Generation, ylabel Penalty value contains 2 objects of type scatter. These objects represent Best penalty value, Mean penalty value.

ga stopped because it exceeded options.MaxGenerations.
sol2 = struct with fields:
     b1: 3
    b45: [2×1 double]
     h1: 60
    h23: [2×1 double]
    h45: [2×1 double]
    w23: [2×1 double]

fval2 = 
6.4803e+04
exitflag2 = 
    SolverLimitExceeded

制約を追加すると目的が増加するだけなので、目的の値が増加します。

解を表示し、その境界と比較します。

widths = [sol2.b1;widthlist(sol2.w23(1));widthlist(sol2.w23(2));sol2.b45];
heights = [sol2.h1;heightlist(sol2.h23(1));heightlist(sol2.h23(2));sol2.h45];
widthbounds = [b1.LowerBound b1.UpperBound;
    widthlist(1) widthlist(end);
     widthlist(1) widthlist(end);
    b45.LowerBound b45.UpperBound];
heightbounds = [h1.LowerBound h1.UpperBound;
     heightlist(1) heightlist(end);
     heightlist(1) heightlist(end);
    h45.LowerBound h45.UpperBound];
T = table(widths,heights,widthbounds,heightbounds,...
    'VariableNames',["Width" "Height" "Width Bounds" "Height Bounds"])
T=5×4 table
    Width     Height    Width Bounds    Height Bounds
    ______    ______    ____________    _____________

         3        60       1      5       30    65   
       3.1        55     2.4    3.1       45    60   
       2.6        50     2.4    3.1       45    60   
     2.286     45.72       1      5       30    65   
    1.8532    34.004       1      5       30    65   

制限を受ける唯一のソリューション変数は 2 番目のセクションの幅で、これは最大値の 3.1 です。

参考文献

[1] Thanedar、P.B.、および G.N. Vanderplaats。"Survey of Discrete Variable Optimization for Structural Design." Journal of Structural Engineering 121 (3), 1995, pp. 301–306.

参考

| |

トピック