Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method CheckOptimizerRunController () as stream[JSON] 
 | 
{ 
 | 
  Description: 
 | 
  [* 
 | 
    Check with the `LibOpt_OptimizerRunController` whether this `LibOpt_Run` can start. 
 | 
    Then start the run once the `LibOpt_OptimizerRunController` gives its approval. 
 | 
  *] 
 | 
  TextBody: 
 | 
  [* 
 | 
    // evr3 Apr-26-2022 (created) 
 | 
     
 | 
    snapshotruncontroller := LibOpt_SnapshotOptimizerRunController::Create( this, this.RequestedOn() ); 
 | 
    // Create the controller run. 
 | 
    // Note: We don't pass objects from the optimizer components library to the dataset controller. 
 | 
    // This is to ensure that the transaction doesn't put a lock on the dataset of the LibOpt_Run.   
 | 
    // Note2: The run controller will throw an error if it is impossible to start a run.  
 | 
    controllerrun := LibOpt_OptimizerRunController::GetRunControllerDataset() 
 | 
                     ->LibOpt_ControllerRun::Create( this.Optimizer().Optimization().DatasetName(), 
 | 
                                                     this.MDSID(), 
 | 
                                                     this.OptimizerName(), 
 | 
                                                     this.Key(), 
 | 
                                                     this.RunNr(),  
 | 
                                                     this.RequestedOn(),  
 | 
                                                     this.RequestedThreadsRunController() ); 
 | 
    // Check with the run controller if the run satisfies all conditions 
 | 
    canstart := controllerrun->CanStart();  
 | 
    // Otherwise, keep polling the run controller until the run satisfies the conditions.  
 | 
    canstart := controllerrun->PollOptimizerRunController( canstart ); 
 | 
    result := this->StartAfterPreprocessing( canstart, snapshotruncontroller ); 
 | 
     
 | 
    // Tell the run controller that the run has ended and that any reservations for this LibOpt_Run can be released.  
 | 
    result->|controllerrun->End() 
 | 
    // Handle the error that is thrown when it is impossible to start a run. 
 | 
             ->Exception() 
 | 
             ->LibOpt_OptimizerRunController::HandleExceptionRunController( this, snapshotruncontroller ); 
 | 
     
 | 
    return result; 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |