Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method GetOptimalValue ( 
 | 
  MPVariable var 
 | 
) as Real 
 | 
{ 
 | 
  Description: 'Return the optimal value of a variable and unscale it' 
 | 
  TextBody: 
 | 
  [* 
 | 
    value := 0.0; // To prevent the noise (0.00000x) to be scaled and treated as a planned quantity. 
 | 
     
 | 
    // in case apply noise threshold = true  
 | 
    // and value in CPLEX <= cplex accuracy, then we take the value to be 0.  
 | 
    // otherwise we go inside the if and scale the variable and apply further noise filtering 
 | 
    if( not this.ApplyNoiseThreshold() or guard( abs( var.OptimalValue() ) > this.SmallestFeasibilityTolerance(), false ) ) 
 | 
    { 
 | 
      varvalue := this.FilterCPLEXNoise( var ); // get optimal value and reduce some noise on the cplex value used  
 | 
      unscaledoptvalue := varvalue * CapacityPlanningSuboptimizer::GetVariableScaleFactor( typeofexpression( var ) ); 
 | 
      unscaledoptvalue_int := unscaledoptvalue.Round( 0 );  
 | 
      noisethreshold := this.MacroPlan().GlobalParameters_MP().NoiseThresholdOptimizerOutput(); 
 | 
      // The unscaled optimal value must be greater than the noise threshold, otherwise we consider the optimal value 0 
 | 
      if( not this.ApplyNoiseThreshold() or abs( unscaledoptvalue - unscaledoptvalue_int ) > noisethreshold ) 
 | 
      { 
 | 
        value := unscaledoptvalue; 
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        // case: apply noise threshold = true  
 | 
        //       and difference from integer is <= noisethreshold  
 | 
        value := unscaledoptvalue_int;      
 | 
      } 
 | 
    } 
 | 
     
 | 
    return value; 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |