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