admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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' }
}