| Quintiq file version 2.0 | 
| #parent: #root | 
| Method FixVariableStyleGuide ( | 
|   MPVariable var, | 
|   Real bound, | 
|   Boolean setuppperbound, | 
|   Boolean setlowerbound, | 
|   Boolean applyscaling | 
| ) const | 
| { | 
|   Description: 'fixing cplex variables according to modeling style guide' | 
|   TextBody: | 
|   [* | 
|     if (applyscaling )  | 
|     { | 
|       bound := this.ScaleVariable( var, bound );   // scale the bound   | 
|     } | 
|      | 
|     if( var.VariableType() = 'Binary' or var.VariableType() = 'Integer' ) | 
|     { | 
|       if ( setlowerbound )  | 
|       { | 
|         var.LowerBound( bound - 0.1 ); | 
|       } | 
|       if ( setuppperbound )  | 
|       { | 
|         var.UpperBound( bound + 0.1 ); | 
|       } | 
|     } | 
|     else | 
|     { | 
|       // Scale everything by a big factor to avoid the epsilon arithmetic of Quill | 
|       big := 1e+10; | 
|       // guard against a MaxReal upper bound, or MinReal lower bound from the init variables | 
|       lb := Real::MinReal(); | 
|       ub := Real::MaxReal(); | 
|       if( var.LowerBound().IsFinite() ) | 
|       { | 
|         lb := var.LowerBound() * big; | 
|       } | 
|       if( var.UpperBound().IsFinite() ) | 
|       { | 
|         ub := var.UpperBound() * big; | 
|       } | 
|       opt := bound * big; | 
|       | 
|       lb := maxvalue( lb, minvalue( ub, opt ) ) | 
|       ub := minvalue( ub, maxvalue( lb, opt ) ) | 
|       | 
|       // Avoid very small range between lb and ub: | 
|       // Compare the bound range to 1e-10, also using scaling | 
|       if( ub - lb <= 1e-10 * big ) | 
|       { | 
|         ub := lb; | 
|       } | 
|       | 
|       // Unscale the values and apply them | 
|       if ( setlowerbound )  | 
|       { | 
|         var.LowerBound( lb / big ); | 
|       } | 
|       if ( setuppperbound )  | 
|       { | 
|         var.UpperBound( ub / big ); | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |