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/algorithmnsDirectories 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:
Node icon (.svg, .jpg, .png, .jpeg, .ico, .bmp)
Documentation page in the help system (.html)
Configuration (.cfg)
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: settings PyOSDesignPoint with algorithm settings. Access input using kwargs["settings"]
.Outputs: unsigned int Maximum number of expected design evaluations. InitializeAlgorithm(args)
Initializes the algorithm with the input values.
Inputs: parameters PyParameterManager with parametrization start designs PyOSDesignContainer with start designs responses PyOSDesignPoint with defined responses criteria PyOSCriterionContainer with defined criteria seed integer with seed used by optiSLang settings PyOSDesignPoint with algorithm settings PyOSDesignPoint optiSLang 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: bool with the success value of the initialization GetNextDesigns(args)
Returns the next designs that must be calculated by the solver defined in optiSLang.
Inputs: PyOSDesignPoint optiSLang 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 designs PyOSDesignContainer with expected designs SetResults(args)
Sets the results calculated by the solver defined in optiSLang.
Inputs: designs PyOSDesignContainer with expected designs including calculated responses PyOSDesignPoint optiSLang 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: bool with the success value of the function Appraise(args)
Appraises the last set results.
Inputs: PyOSDesignPoint optiSLang 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: bool with 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 designs PyOSDesignContainer with start designs responses PyOSDesignPoint with defined responses criteria PyOSCriterionContainer with defined criteria seed integer with seed used by optiSLang settings PyOSDesignPoint with algorithm settings PyOSDesignPoint optiSLang 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: bool with the success value of the adaption IsTerminated(args)
Decides if the algorithm is terminated.
Inputs: PyOSDesignPoint optiSLang 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: bool with the termination state IsConverged(args)
Decides if the algorithm is converged.
Inputs: PyOSDesignPoint optiSLang 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: bool with the convergency state GetSettings(args)
Returns the internally used algorithm settings to show them in the dialog.
Inputs: PyOSDesignPoint optiSLang 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 PyOSDesignPoint with 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: PyOSDesignPoint with algorithm settings PyOSDesignPoint optiSLang 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: bool with the success value of the check
The following functions are optional:
IsOptimization(args)
Decides if the algorithm uses optimization parameters.
Inputs: PyOSDesignPoint optiSLang 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: bool which is true if the algorithm uses optimization parameters IsStochastic(args)
Decides if the algorithm uses stochastic parameters.
Inputs: PyOSDesignPoint optiSLang 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: bool which 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: PyOSDesignPoint Custom algorithm settings Outputs: List of capabilities Each 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: