Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod Create (LibOpt_OptimizerRunController controller, String datasetname, Key datasetkey,  
 | 
  String optimizername, Key runkey, Number runnr,  
 | 
  DateTime requestedon, Number threadsrequested) as LibOpt_ControllerRun 
 | 
{ 
 | 
  Description: 
 | 
  [* 
 | 
    Create a new `LibOpt_ControllerRun`.  
 | 
    This `LibOpt_ControllerRun` is implicitly linked to a `LibOpt_Run` through the `LibOpt_ControllerRun.DatasetKey` and `LibOpt_ControllerRun.RunNr` attributes. 
 | 
  *] 
 | 
  TextBody: 
 | 
  [* 
 | 
    // evr3 Apr-26-2022 (created) 
 | 
    if( controller.ConcurrentRunsMax() <= 0 ) 
 | 
    { 
 | 
      // Throw an error if ConcurrentRunsMax is equal to zero, as this implies that no runs can start.  
 | 
      // This error is handled in HandleExceptionRunController and it will create a snapshot to inform the user.  
 | 
      error( Translations::LibOpt_OptimizerRunController_MaxConcurrentRunsIsZero() ); 
 | 
    } 
 | 
     
 | 
    if( threadsrequested > controller.CPUThreadsMax() ) 
 | 
    { 
 | 
      // Throw an error if more threads are requested than there are availble.  
 | 
      // The run controller works first-in-first-out. By throwing the error, we ensure that all other runs don't have to wait because this run cannot be started.  
 | 
      // This error is handled in HandleExceptionRunController and it will create a snapshot to inform the user.  
 | 
      error( Translations::LibOpt_OptimizerRunController_ErrorRequestedThreads( threadsrequested, controller.CPUThreadsMax() ) ); 
 | 
    } 
 | 
     
 | 
    // Remove old stopped runs before starting new ones. 
 | 
    controller.DeleteStoppedOptimizerRuns(); 
 | 
     
 | 
    run := controller.ControllerRun( relnew, 
 | 
                                     DatasetName := datasetname, 
 | 
                                     DatasetKey := datasetkey, 
 | 
                                     OptimizerName := optimizername, 
 | 
                                     RunKey := runkey, 
 | 
                                     RunNr := runnr, 
 | 
                                     RequestedOn := requestedon, 
 | 
                                     CPUThreadsRequested := threadsrequested 
 | 
                                     ); 
 | 
    return run; 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |