Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method SetMaxNrOfTrees ( 
 | 
  GraphProgram program 
 | 
) 
 | 
{ 
 | 
  Description: 'Calculate maximum number of trees allowed or needed for a graph program' 
 | 
  TextBody: 
 | 
  [* 
 | 
    upperbound := 1.0 
 | 
    graph := program.Graph( MEIO_Treeify::GetGraphName(this.MEIO_Engine().Product_MP().Name()), this ); 
 | 
     
 | 
    // Calculate upperbound of number of tries by the product of ( # parents of each node ) 
 | 
    traverse( graph, Nodes, n ) 
 | 
    { 
 | 
      upperbound := upperbound * maxvalue( 1.0, n.Input( relsize ) );  
 | 
    } 
 | 
     
 | 
    // Take min value of theoretical upperbound and parameter value 
 | 
    cap := minvalue( upperbound, 
 | 
                     this.MEIO_Parameters().MaxNrOfTreesPerGraph() ); 
 | 
     
 | 
    this.MEIO_Engine().MaxNrOfTrees( [Number]cap ); 
 | 
  *] 
 | 
} 
 |