yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
44
Quintiq file version 2.0
#parent: #root
Method NewIterationPart (LibOpt_Task task)
{
  Description:
  [*
    React to the creation of a new `LibOpt_Task`.
    This means in some cases that two new `Algorithms` need to be created.
    
    The `Algorithms` are used to store messages for the channel.
    One `Algorithm` is used to store messages sent by all upstream and downstream iteration part executions (including itself).
    The other `Algorithm` only stores the messages sent by all upstream iteration part executions (including itself).
    This one will be copied when a new downstream iteration part is created, as a new downstream iteration part needs access to the messages from its upstream iteration parts, but not its sibling iteration parts.
  *]
  TextBody:
  [*
    algorithm1 := null( Algorithm, owning );
    algorithm2 := null( Algorithm, owning );
    
    channel := this.Channel();
    
    if( this.IsNew() )
    {
      algorithm1 := LibOpt_Utility::ConstructMathematicalProgramWithoutAnalysis();
      algorithm1.StoreReal( LibOpt_Channel::Algorithm_Count(), NumberToReal::ISOConverter().Convert( 0 ) );
      algorithm2 := LibOpt_Utility::ConstructMathematicalProgramWithoutAnalysis();
      algorithm2.StoreReal( LibOpt_Channel::Algorithm_Count(), NumberToReal::ISOConverter().Convert( 0 ) );
    }
    else
    {
      parent_id := channel.GetAlgorithmStoreID( task.Parent(), true );
      parent_algorithm := channel.GetAlgorithm( parent_id );
      
      algorithm1 := this.CopyAlgorithm( parent_algorithm );
      algorithm2 := this.CopyAlgorithm( parent_algorithm );
    
      AlgorithmStore::Store( parent_id, & parent_algorithm );
    }
    
    AlgorithmStore::Store( channel.GetAlgorithmStoreID( task, true ), & algorithm1 );
    AlgorithmStore::Store( channel.GetAlgorithmStoreID( task, false ), & algorithm2 );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}