Skip to content

run_optimization_problem: Allow passing arguments to problem class

Tjerk Vreeken requested to merge add-arguments-runopt into maintenance/2.3.x

BACKPORT NOTE: This is a backported feature, not a bug fix. It turns out that people were forced to use global variables to pass information to the optimization problem, which is a typical demand/requirement. We do not want to encourage the use of global variables, so instead we backport this feature such that users can properly pass arguments instead.

The functions run_optimization_problem() and run_simulation_problem() are commonly used to instantiate and run models. Sometimes it can be useful to override some default instance/class variables on the problem class. This commit makes that much easier by allowing one to pass additional keyword arguments to run_optimization_problem() and run_simulation_problem(), which are then passed through to the problem class's init().

Note that additional positional arguments are not allowed for future compatibility. We may want to pass additional arguments ourselves to a problem class in the future.

Merge request reports