haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
38
39
40
41
42
Quintiq file version 2.0
#parent: #root
Method UpdateMinMaxBound (
  Real bound,
  MPVariable variable
)
{
  Description: 'Updates the minimum lowerbound and maximum upperbound of the scaling type'
  TextBody:
  [*
    // Select the scaling type associated with this variable
    
    scalingtypename := CapacityPlanningSuboptimizer::GetVariableScaleType( typeofexpression( variable ).ShortName() );
    
    algorithmrun := this.MacroPlan().GetLastAlgorithmRun(); 
    scalingtype := algorithmrun.GetScalingType( scalingtypename );
    
    // Update the minimum/maximum bound of this scaling type
    newbound := abs( bound );
    if( newbound <> 0 and newbound.IsFinite() )
    {
       //'moving all updates on variables into the handle feasible, so methods can be read only. Originally we call with the unscaled(non cplex value) then divide to get cplex bound
       //  so now we start with the actual cplex bound in the call so no need to scale by dividing. Only difference would be squashing tiny values. Hence commenting out following:  
      /* >>                             
      varscalefactor := CapacityPlanningSuboptimizer::GetVariableScaleFactor( typeofexpression( variable ) ); 
      newbound := newbound / varscalefactor;
      <<*/
      
      if( newbound < scalingtype.MinBound() )
      {
        scalingtype.MinBound( newbound );
        scalingtype.VariableNameMinBound( variable.Name() );
      }
      if( newbound > scalingtype.MaxBound() )
      {
        scalingtype.MaxBound( newbound );
        scalingtype.VariableNameMaxBound( variable.Name() );
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}