lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
43
44
45
Quintiq file version 2.0
#parent: #root
Method RunMEIO (
  ProductInStockingPoint_MPs pisps
)
{
  Description: 'Run the MEIO optimizers for the input pisps. Initially it is launched for a capped number of products, and in post-processing of one product optimization, optimization is launched for a new product.'
  TextBody:
  [*
    // Reset attributes and relations
    if ( pisps.Size() > 0 )
    {
      this.MEIO_Parameters().Product_MP( relflush );
      this.MEIO_Parameters().IsRunning( true );
      
      // Construct for products to be used for optimization 
      products := construct( Product_MPs );
      
      
      // Traverse all products, reset attributes and set relation to leaf products that will be used in the optimization
      traverse( pisps, Elements.Product_MP, p )
      {
        p.MEIO_Successful( false );
        p.MEIO_IsOptimized( false );
        if( p.IsLeaf() )
        {
            products.Add( p );
            this.MEIO_Parameters().Product_MP( relinsert,
                                               p );     
        }
      }
      
      // Cap the number of products for which optimization will be launched initially. 
      cap := 1; // originally cap > 1 was used to have parallel R sessions
      capped := products.SelectRange( 0, cap );
      
      // Start optimization for selected products
      traverse( capped, Elements, product )
      {
        m := MEIO_Engine::Create( product );
        m.MEIO_Treeify().Optimize();
     }
    }
  *]
}