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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Quintiq file version 2.0
#parent: #root
Method StartIteration (LibOpt_Task task, LibOpt_TaskContextIterator context, LibOpt_Link link, 
  LibOpt_Scope scope) as stream[JSON]
{
  Description: 'Start a new iteration by calling the next component correctly.'
  TextBody:
  [*
    reactive_calls := LibOpt_CurrentTransaction::GetSpawnedReactiveCalls();
    time := OS::PrecisionCounter();
    
    continue := stream[JSON]::Success();
    // After aborting the optimizer, we still have to execute any post-processing links and their downstream tasks. 
    if( not task.IsAborted() 
        or link.IsPostProcessing() 
        or task.IsPostProcessing() )
    {
      continue := this.Continue( task, link, scope );
    }
    
    result := stream[JSON]::Success();
    if( this.ForceInOneTransaction() or this.Run().InOneTransaction() or reactive_calls = LibOpt_CurrentTransaction::GetSpawnedReactiveCalls() )
    {
      context.NrOfIterations( context.NrOfIterations() + 1 );
      
      if( reactive_calls <> LibOpt_CurrentTransaction::GetSpawnedReactiveCalls() )
      {
        LibOpt_SnapshotWarning::Throw( task,
                                       Translations::LibOpt_Iterator_NotInOneTransaction( this.Name(), LibOpt_CurrentTransaction::GetSpawnedReactiveCallNames( time ) ),
                                       Translations::LibOpt_Iterator_NotInOneTransaction_Solution() );
      }
    }
    else
    {
      finish := continue->|
                this->Repeat( task, context );
      result := continue->Merge( finish );
      context.NrOfSubtasks( context.NrOfSubtasks() + 1 );
    }
    
    return result;
  *]
}