chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: #root
MethodOverride GetScope (
  LibOpt_Task task
) as LibOpt_Scope
{
  Description:
  [*
    This method returns a scope from the set of scopes that can be used for the next iteration.
    
    When entered for the first time, the set of scopes is created.
  *]
  TextBody:
  [*
    context := task.TaskContext().astype( LibOpt_TaskContextIterator );
    scope := null( LibOpt_Scope );
    
    // Enter if this is the first time a task 
    if( context.CurrentIteration() = 0 )
    {
      scopes := this.GetPartition( task );
      
      traverse( scopes, Elements, sc )
      {
        sc.TaskContextIterator( relset, context );
      }
    }
    
    if( context.Scope( relsize ) > 0 )
    {
      scope := context.FirstScope();
      //When scope is selected, delete relation such that it cannot be selected again.
      scope.TaskContextIterator( relflush );
    }
    
    return scope
  *]
}