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
Quintiq file version 2.0
#parent: #root
Method FreezeVariableUpperBound (
  MPVariable var,
  Real upperbound,
  Boolean isfreezewithslack
) const
{
  Description: 'Set upper bound of the variable, with scaling factor influence'
  TextBody:
  [*
    // soh yee Mar-15-2015 (created)
    
    upperbound := this.ScaleVariable( var, upperbound );   // scale the upper bound
    
    // (12110) Haikal Pribadi
    // Freeze small values (1e-6) to zero, but give a warning for us to eventually debug when we can reproduce
    cplexaccuracy := this.SmallestFeasibilityTolerance(); 
    if( abs( upperbound ) <= cplexaccuracy )
    {
      if( 0.0 < abs( upperbound ) )
      {
        info( "WARNING: Variable '", var.Name(), "' has encountered an upper bound value <= ", cplexaccuracy,", rounding to 0.0" );
      }
      upperbound := 0.0;
    }
    
    // If this is optimizer output, we have to add a small epsilon to prevent infeasibilities
    if( isfreezewithslack )
    {
      upperbound := upperbound + 1e-4;
    }
    
    var.UpperBound( upperbound );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}