yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
FunctionOverride CalcEstimate
{
  TextBody:
  [*
    // Select the MoveStep related to the source and destination that has last been tried
    lastmovestepsource := maxselect( this, SourceInventorySpecification.MoveStep, movestep, true, guard( movestep.Iteration().IterationNumber(), 0 ) );
    lastmovestepdestination := maxselect( this, DestinationInventorySpecification.MoveStep, movestep, true, guard( movestep.Iteration().IterationNumber(), 0 ) );
    
    // Calculate the expected benefit of the swap move
    estimate := this.Quantity() * ( guard( lastmovestepdestination.BenefitPerQtyLatestAttempt(), 0.0 ) - guard( lastmovestepsource.BenefitPerQtyLatestAttempt(), 0.0 ) )
    
    // If there is no quantity at the source, then the swap move does not make sense so we give it a negative estimate
    if( this.SourceInventorySpecification().TargetInQuantity_DELETED_Nov19() <= 0 )
    {
      estimate := -10;
    }
    
    // Reduce the estimate if the last X times that this move was tried it did not find an improvement
    estimate := this.GetCorrectionEstimateForPreviousFailures() * estimate;
    
    this.Estimate( estimate );
  *]
}