Solver utilities (cpmpy.solvers.utils)

Utilities for handling solvers

Contains a static variable builtin_solvers that lists CPMpy solvers (first one is the default solver by default)

List of functions

param_combinations

Recursively yield all combinations of param values

class cpmpy.solvers.utils.SolverLookup[source]
static base_solvers()[source]

Return ordered list of (name, class) of base CPMpy solvers

First one is default

static get(name=None, model=None)[source]

get a specific solver (by name), with ‘model’ passed to its constructor

This is the preferred way to initialise a solver from its name

static lookup(name=None)[source]

lookup a solver _class_ by its name

warning: returns a ‘class’, not an object! see get() for normal uses

static solvernames()[source]
cpmpy.solvers.utils.get_supported_solvers()[source]

Returns a list of solvers supported on this machine.

Returns

a list of SolverInterface sub-classes :list[SolverInterface]:

cpmpy.solvers.utils.param_combinations(all_params, remaining_keys=None, cur_params=None)[source]

Recursively yield all combinations of param values

For example usage, see examples/advanced/hyperparameter_search.py

  • all_params is a dict of {key: list} items, e.g.:

    {‘val’: [1,2], ‘opt’: [True,False]}

  • output is an generator over all {key:value} combinations of the keys and values. For the example above: generator([{‘val’:1,’opt’:True},{‘val’:1,’opt’:False},{‘val’:2,’opt’:True},{‘val’:2,’opt’:False}])