From Cornell University Computational Optimization Open Textbook - Optimization Wiki
|
|
| Line 72: |
Line 72: |
|
| |
|
| === Code === | | === Code === |
| The following code is used to solve the above example in the General Algebraic Modeling System (GAMS): | | The following code is used to solve the above example in the General Algebraic Modeling System (GAMS):<br> |
| Variable z; | | <code>Variable z;<br> |
| | | Positive Variables x1, x2;<br> |
| Positive Variables x1, x2; | | Binary Variables y1, y2;<br> |
| | | Equations obj, c1, c2, c3, c4, c5, c6, c7;<br> |
| Binary Variables y1, y2; | | obj.. z =e= y1 + y2 + sqr(x1) + sqr(x2);<br> |
| | | c1.. sqr(x1 - 2) - x2 =l= 0;<br> |
| Equations obj, c1, c2, c3, c4, c5, c6, c7; | | c2.. x1 - 2*y1 =g= 0;<br> |
| | | c3.. x1 - x2 - 3*sqr(1 - y1) =g= 0;<br> |
| obj.. z =e= y1 + y2 + sqr(x1) + sqr(x2); | | c4.. x1 + y1 - 1 =g= 0;<br> |
| | | c5.. x2 - y2 =g= 0;<br> |
| c1.. sqr(x1 - 2) - x2 =l= 0; | | c6.. x1 + x2 =g= 3*y1;<br> |
| | | c7.. y1 + y2 =g= 1;<br> |
| c2.. x1 - 2*y1 =g= 0; | | x1.lo = 0; x1.up = 4;<br> |
| | | x2.lo = 0; x2.up = 4;<br> |
| c3.. x1 - x2 - 3*sqr(1 - y1) =g= 0; | | model Example /all/;<br> |
| | | option minlp = bonmin;<br> |
| c4.. x1 + y1 - 1 =g= 0; | | option optcr = 0;<br> |
| | | solve Example minimizing z using minlp;<br> |
| c5.. x2 - y2 =g= 0; | | display z.l, x1.l, x2.l, y1.l, y2.l;</code><br> |
| | |
| c6.. x1 + x2 =g= 3*y1; | |
| | |
| c7.. y1 + y2 =g= 1; | |
| | |
| x1.lo = 0; x1.up = 4; | |
| | |
| x2.lo = 0; x2.up = 4; | |
| | |
| y1.l = 1; y2.l = 1;
| |
| | |
| model Example /all/; | |
| | |
| | |
| option minlp = BONMIN; | |
| | |
| option optcr = 0; | |
| | |
| solve Example MINIMIZING z using MINLP; | |
| | |
| display z.l, x1.l, x2.l, y1.l, y2.l; | |
|
| |
|
| ==Conclusion== | | ==Conclusion== |
|
| |
|
| ==References== | | ==References== |
Revision as of 08:05, 26 November 2021
Author: Yousef Aloufi (CHEME 6800 Fall 2021)
Introduction
Theory
Example
Numerical Example
Minimize

Subject to 









Solution
Step 1a: Start from

and solve the NLP below:
Minimize 
Subject to 







Solution: 
, Upper Bound = 7
Step 1b: Solve the MILP master problem with OA for
:
![{\displaystyle f{\big (}x{\big )}={\big (}x_{1}{\big )}^{2}+{\big (}x_{2}{\big )}^{2},~~\bigtriangledown f{\big (}x{\big )}=[2x_{1}~~~~2x_{1}]^{T}~~for~~x^{*}=[2~~~~1]^{T}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/3aa00d3f49988a196d93388e7ac41da58fc00066)
![{\displaystyle f{\big (}x^{*}{\big )}+\bigtriangledown f{\big (}x^{*}{\big )}^{T}{\big (}x-x^{*}{\big )}=5+[4~~~~2]{\begin{bmatrix}x_{1}-2\\x_{2}-1\end{bmatrix}}=5+4{\big (}x_{1}-2{\big )}+2{\big (}x_{2}-1{\big )}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/29222aefe55bdb63f346ae1a3c21c27fe7efa013)
![{\displaystyle g{\big (}x{\big )}={\big (}x_{1}-2{\big )}^{2}-x_{2},~~\bigtriangledown g{\big (}x{\big )}=[2x_{1}-4~~~~-1]^{T}~~for~~x^{*}=[2~~~~1]^{T}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/f025d4d61d63efd6a87b01d8e7848abc520f2bfa)
![{\displaystyle g{\big (}x^{*}{\big )}+\bigtriangledown g{\big (}x^{*}{\big )}^{T}{\big (}x-x^{*}{\big )}=-1+[0~~~~-1]{\begin{bmatrix}x_{1}-2\\x_{2}-1\end{bmatrix}}=-x_{2}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/52bbf7d8d87d53306f2542ef0f6ff2b8a75ce4a9)
Minimize

Subject to 










MILP Solution:
, Lower Bound = 6
Lower Bound < Upper Bound, Integer cut:
Step 2a: Start from
and solve the NLP below:
Minimize

Subject to 







Solution: 
, Upper Bound = 6
Upper Bound = 6 = Lower Bound, Optimum!
Optimal Solution for the MINLP:
Code
The following code is used to solve the above example in the General Algebraic Modeling System (GAMS):
Variable z;
Positive Variables x1, x2;
Binary Variables y1, y2;
Equations obj, c1, c2, c3, c4, c5, c6, c7;
obj.. z =e= y1 + y2 + sqr(x1) + sqr(x2);
c1.. sqr(x1 - 2) - x2 =l= 0;
c2.. x1 - 2*y1 =g= 0;
c3.. x1 - x2 - 3*sqr(1 - y1) =g= 0;
c4.. x1 + y1 - 1 =g= 0;
c5.. x2 - y2 =g= 0;
c6.. x1 + x2 =g= 3*y1;
c7.. y1 + y2 =g= 1;
x1.lo = 0; x1.up = 4;
x2.lo = 0; x2.up = 4;
model Example /all/;
option minlp = bonmin;
option optcr = 0;
solve Example minimizing z using minlp;
display z.l, x1.l, x2.l, y1.l, y2.l;
Conclusion
References