Algorithms

optiSLang allows you to extend the algorithms by using common script interfaces.

To use custom script algorithms, the scripts must fulfill the naming conventions *_ca.py or *_algo.py and should be placed in any of the following locations:

  • [installation path]/scripting/algorithmns

  • Directories specified by SC_AlternativeCADirectories configuration settings.

  • Directories specified by the environment variable OSL_ALT_CA_SEARCH_DIRS, separated by the native environment separator (; on Windows platforms or : on Linux platforms).

Custom script algorithms found in these locations are loaded when the application starts and are then available for use within optiSLang.

Optionally, the following file types with the same filename and in the same directory can be used as:

The following functions are required in the Python script:

  • GetMaxNumberOfDesigns(kwargs)

    Returns the maximum number of design evaluations requested by the algorithm before termination.

    Inputs:settingsPyOSDesignPoint with algorithm settings. Access input using kwargs["settings"].
    Outputs: unsigned intMaximum number of expected design evaluations.
  • InitializeAlgorithm(args)

    Initializes the algorithm with the input values.

    Inputs:parameters PyParameterManager with parametrization
    start designsPyOSDesignContainer with start designs
    responsesPyOSDesignPoint with defined responses
    criteriaPyOSCriterionContainer with defined criteria
    seedinteger with seed used by optiSLang
    settingsPyOSDesignPoint with algorithm settings
    PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwith the success value of the initialization
  • GetNextDesigns(args)

    Returns the next designs that must be calculated by the solver defined in optiSLang.

    Inputs:PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:next designsPyOSDesignContainer with expected designs
  • SetResults(args)

    Sets the results calculated by the solver defined in optiSLang.

    Inputs:designsPyOSDesignContainer with expected designs including calculated responses
    PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwith the success value of the function
  • Appraise(args)

    Appraises the last set results.

    Inputs:PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwith the success value of the function
    (ATTENTION: NOT the success value of the appraisal!)
  • Adapt(args)

    Adapts the next designs which are expected to be calculated by the solver defined in optiSLang.

    Inputs:parameters PyParameterManager with parametrization
    start designsPyOSDesignContainer with start designs
    responsesPyOSDesignPoint with defined responses
    criteriaPyOSCriterionContainer with defined criteria
    seedinteger with seed used by optiSLang
    settingsPyOSDesignPoint with algorithm settings
    PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwith the success value of the adaption
  • IsTerminated(args)

    Decides if the algorithm is terminated.

    Inputs:PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwith the termination state
  • IsConverged(args)

    Decides if the algorithm is converged.

    Inputs:PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwith the convergency state
  • GetSettings(args)

    Returns the internally used algorithm settings to show them in the dialog.

    Inputs:PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:list with one PyOSDesignPointwith internal settings
    each entry represents name and value of one setting
    * "name": unicode - name of setting
    * "value": PyOSDesignEntry - value of setting
  • CheckSettings(args)

    Checks the internally used algorithm settings.

    Inputs:PyOSDesignPointwith algorithm settings
    PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwith the success value of the check

The following functions are optional:

  • IsOptimization(args)

    Decides if the algorithm uses optimization parameters.

    Inputs:PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwhich is true if the algorithm uses optimization parameters
  • IsStochastic(args)

    Decides if the algorithm uses stochastic parameters.

    Inputs:PyOSDesignPointoptiSLang variables
    * OSL_PROJECT_DIR - contains the absolute path of the current project (*.opd)
    * OSL_WORKING_DIR - contains the absolute path of the current working directory
    * OSL_CUSTOM_SCRIPT_DIR - contains the absolute path of the current script file
    * OSL_RLS_VER - representing the version number of optiSLang
    * OSL_RLS_REV - representing the revision number of optiSLang
    * OSL_RLS_FLG - is empty unless a specific version of optiSLang is used
    Outputs:boolwhich is true if the algorithm uses stochastic parameters
  • GetRequiredLicenseCaps(args)

    Returns license related information. The return value tells optiSLang which capabilities are used. The appropriate license is locked based on the list of capabilities. Common capabilities in the context of custom algorithms are:

    • OSL_CAP_SENSITIVITY

    • OSL_CAP_ROBUSTNESS

    • OSL_CAP_RDO

    Inputs:PyOSDesignPointCustom algorithm settings
    Outputs:List of capabilitiesEach entry defines an identifier for the required license capability

Sample scripts can be found in [installation path]\optiSLang\scripting\algorithms.

The basic relationship between functions and the algorithm is shown in the following workflow: