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(); 
 | 
     } 
 | 
    } 
 | 
  *] 
 | 
} 
 |