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
38
Quintiq file version 2.0
#parent: #root
Method UpdateMinMaxCoefficient (
  Real coefficient,
  MPConstraint constr,
  MPVariable variable
)
{
  Description: 'Updates the minimum and maximum coefficient of this coefficientscaling'
  TextBody:
  [*
    // Select the CoefficientScaling associated with this constraint and this variable
    
    workaroundname := 'MP' + constr.Name() + 'Constraint'; 
    constraintscalingtypename := CapacityPlanningSuboptimizer::GetConstraintScaleType( workaroundname ); // this is broken: typeofexpression( constr ).ShortName() );
    variablescalingtypename := CapacityPlanningSuboptimizer::GetVariableScaleType(  typeofexpression( variable ).ShortName() );
    
    coefficientscaling := this.GetScalingType( constraintscalingtypename, variablescalingtypename );
    
    // Update the min and max coefficient of this CoefficientScaling
    coeff := abs( coefficient );
    if( not isnull( coefficientscaling ) and coeff <> 0 and coeff.IsFinite() )
    {
      if( coeff < coefficientscaling.MinCoefficient() )
      {
        coefficientscaling.MinCoefficient( coeff );
        coefficientscaling.ConstraintNameMinCoefficient( constr.Name() );
        coefficientscaling.VariableNameMinCoefficient( variable.Name() );
      }
      if( coeff > coefficientscaling.MaxCoefficient() )
      {
        coefficientscaling.MaxCoefficient( coeff );
        coefficientscaling.ConstraintNameMaxCoefficient( constr.Name() );
        coefficientscaling.VariableNameMaxCoefficient( variable.Name() );
      }
    }
  *]
}