Answers to: several if then or if else using gamshttp://www.or-exchange.com/questions/12268/several-if-then-or-if-else-using-gams<p>Dear All,</p>
<p>I am trying to code several if then or if else using gams code but I cannot get it right.</p>
<p>my formulas and gams code are below. is there any easy way to write these codes?</p>
<p>Z1, Z2, and Z3 are binary variables. I try to wrote on of the equations as follow</p>
<p>enWed, 03 Jun 2015 22:52:11 -0400Answer by erwinhttp://www.or-exchange.com/questions/12268/several-if-then-or-if-else-using-gams/12444<p>When you run an MINLP model and you see: "An equation in the pre-triangular part of the model cannot be solved because the critical slack is at a bound", this probably means the relaxed MINLP (RMINLP) is already infeasible. CONOPT gives a detailed message in the listing file how it deduced the model was infeasible in the preprocessor. This should make it easy to diagnose the problem.</p>
<p>When solving a MINLP it is often a good idea to first make sure that the RMINLP solves ok. </p>erwinWed, 03 Jun 2015 22:52:11 -0400http://www.or-exchange.com/questions/12268/several-if-then-or-if-else-using-gams/12444Answer by denizhttp://www.or-exchange.com/questions/12268/several-if-then-or-if-else-using-gams/12358<p>Dear Ehsan,
Thank you very much for your guidance. I define the additional constrains as follows. Since I have ranges for the R values I had to define several constraints for each R range. I also change the R values as you said. Model run without error but model statistic gives a message stating that </p>
<p><strong> Warning </strong> The variance of the derivatives in the initial point is large (= 5.4 ). A better initial point, a better scaling, or better bounds on the variables will probably help the optimization.</p>
<p>"An equation in the pre-triangular part of the model cannot be solved because the critical slack is at a bound".
I have run very simple MIP problem but this is my first MINLP and I really don't know what is this means also I don't know how to even solve the problem.
Thanks again for your time and guidance.</p>
<p>const5(T,P)..lambda(p,t+1))=l= z1(t-1,p) * R1 ;
const5a(T,P)..lambda(p,t+1))=g= z2(t-1,p) * R1 ;
const5b(T,P)..lambda(p,t+1))=l= z2(t-1,p) * R2;
const5c(T,P)..lambda(p,t+1))=g= z3(t-1,p) * R2;
const5d(T,P)..lambda(p,t+1))=l= z3(t-1,p) * R3 ;
const5e(T,P)..lambda(p,t+1))=g= (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (1-z3(t-1,p) ) * R3 ;</p>denizTue, 26 May 2015 01:11:28 -0400http://www.or-exchange.com/questions/12268/several-if-then-or-if-else-using-gams/12358Answer by Ehsanhttp://www.or-exchange.com/questions/12268/several-if-then-or-if-else-using-gams/12269<p>AFAIK, if, ifthen, and other similar keywords in GAMS are used for manipulating data and/or scripting (e.g., writing an algorithm such as benders decomposition). Hence, you cannot use them directly with variables in the statements. In other words, you should use these keywords only with statements involving parameters (i.e., before/after the solve statement) or attributes of variables (i.e., after the solve statement).</p>
<p>PS. Your post is different from the email alert sent by OR-X for an unknown reason. You might want to edit your post to make it clearer for everybody.</p>EhsanTue, 19 May 2015 00:45:37 -0400http://www.or-exchange.com/questions/12268/several-if-then-or-if-else-using-gams/12269