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' } 
 | 
} 
 |