1. 程式人生 > 實用技巧 >《數學模型》 第4章 數學規劃模型

《數學模型》 第4章 數學規劃模型

第4章 數學規劃模型

上一章介紹優化模型,\(x\)表示決策變數\(f(x)\)表示目標函式\(x\)的取值範圍為可行域\(\Omega\),優化模型即

\[\min(\max)f(x),x\in \Omega \]

實際中變數通常有多個,用\(n\)維向量

\[\boldsymbol{x}=(x_1,x_2,\cdots,x_n)^T \]

目標函式\(f(\boldsymbol{x}))\)是多元函式,可行域比較複雜,常用一組不等式\(g_i(\boldsymbol{x})\leqslant 0(i=1,2,\cdots,m)\)來界定,稱為約束條件。即

\[\min_x z=f(\boldsymbol{x})\quad s.t. \quad g_i(\boldsymbol{x})\leqslant 0,i=1,2,\cdots,m \]

4.1 奶製品的生產與銷售

問題分析

優化目標:每天獲利最大
決策:生產計劃,每天多少桶牛奶生產\(A_1\),多少桶生產\(A_2\)
決策變數受到3個條件的限制:原料供應、勞動時間、甲類裝置的加工能力

基本模型

\[\max z=72x_1+64x_2\\ \begin{align}s.t. \quad &x_1+x_2\leqslant 50\\ &12x_1+8x_2\leqslant 480\\ &3x_1\leqslant 100\\ &x_1\geqslant 0,x_2\geqslant 0 \end{align}\]

模型分析與假設

從比例性、可加性、連續性考慮

模型求解

圖解法軟體實現
Lingo程式碼

model:
max=72*x1+64*x2;
[milk] x1+x2<50;
[time] 12*x1+8*x2<480;
[cpct] 3*x1<100;
end

選擇Lingo|Solve輸出結果

  Global optimal solution found.全域性最優解
  Objective value:                              3360.000目標值
  Infeasibilities:                              0.000000
  Total solver iterations:                             2迭代次數
  Elapsed runtime seconds:                          0.06執行時間

  Model Class:                                        LP線性規劃

  Total variables:                      2變數個數
  Nonlinear variables:                  0非線性變數個數
  Integer variables:                    0整數變數個數

  Total constraints:                    4總約束
  Nonlinear constraints:                0

  Total nonzeros:                       7非零值
  Nonlinear nonzeros:                   0



                                Variable           Value        Reduced Cost
                                      X1        20.00000            0.000000
                                      X2        30.00000            0.000000

                                     Row    Slack or Surplus      Dual Price
                                       1        3360.000            1.000000
                                    MILK        0.000000            48.00000
                                    TIME        0.000000            2.000000
                                    CPCT        40.00000            0.000000

選擇Lingo|Range輸出

 Ranges in which the basis is unchanged:

                                       Objective Coefficient Ranges:

                                        Current        Allowable        Allowable
                      Variable      Coefficient         Increase         Decrease
                            X1         72.00000         24.00000         8.000000
                            X2         64.00000         8.000000         16.00000

                                           Righthand Side Ranges:

                                        Current        Allowable        Allowable
                           Row              RHS         Increase         Decrease
                          MILK         50.00000         10.00000         6.666667
                          TIME         480.0000         53.33333         80.00000
                          CPCT         100.0000         INFINITY         40.00000