utils#

gamspy.utils.checkAllSame(iterable1: Sequence, iterable2: Sequence) bool[source]#

Checks if all elements of a sequence are equal to the all elements of another sequence.

Parameters:
iterable1Sequence of Symbols
iterable2Sequence of Symbols
Returns:
bool

Examples

>>> import gamspy as gp
>>> m = gp.Container()
>>> i = gp.Set(m, "i")
>>> j = gp.Set(m, "j")
>>> k = gp.Set(m, "k")
>>> list1 = [i, j]
>>> list2 = [i, j]
>>> gp.utils.checkAllSame(list1, list2)
True
>>> list3 = [i, j, k]
>>> gp.utils.checkAllSame(list1, list3)
False
gamspy.utils.getAvailableSolvers() list[str][source]#

Returns all available solvers.

Returns:
list[str]
Raises:
ModuleNotFoundError

In case gamspy_base is not installed.

Examples

>>> import gamspy.utils as utils
>>> available_solvers = utils.getAvailableSolvers()
gamspy.utils.getDefaultSolvers(system_directory: str) dict[str, str][source]#

Returns the default solver for each problem type.

Parameters:
system_directorystr
Returns:
dict[str, str]

Examples

>>> import gamspy as gp
>>> import gamspy_base
>>> default_solvers = gp.utils.getDefaultSolvers(gamspy_base.directory)
gamspy.utils.getInstallableSolvers(system_directory: str) list[str][source]#

Returns all installable solvers.

Parameters:
system_directorystr
Returns:
list[str]
Raises:
ModuleNotFoundError

In case gamspy_base is not installed.

Examples

>>> import gamspy_base
>>> import gamspy.utils as utils
>>> available_solvers = utils.getInstallableSolvers(gamspy_base.directory)
gamspy.utils.getInstalledSolvers(system_directory: str) list[str][source]#

Returns the list of installed solvers

Returns:
list[str]
Raises:
ModuleNotFoundError

In case gamspy_base is not installed.

Examples

>>> import gamspy_base
>>> import gamspy.utils as utils
>>> installed_solvers = utils.getInstalledSolvers(gamspy_base.directory)
gamspy.utils.getSolverCapabilities(system_directory: str) dict[str, list[str]][source]#

Returns a dictionary where keys are the solvers and values are the capabilities of the solver.

Parameters:
system_directorystr
Returns:
dict[str, list[str]]
gamspy.utils.isin(symbol, sequence: Sequence) bool[source]#

Checks whether the given symbol in the sequence. Needed for symbol comparison since __eq__ magic is overloaded by the symbols.

Parameters:
symbolSymbol

Symbol to check

sequenceSequence

Sequence that holds a sequence of symbols

Returns:
bool

Examples

>>> import gamspy as gp
>>> m = gp.Container()
>>> i = gp.Set(m, "i")
>>> j = gp.Set(m, "j")
>>> k = gp.Set(m, "k")
>>> sets = [i, j]
>>> gp.utils.isin(i, sets)
True
>>> gp.utils.isin(k, sets)
False
gamspy.utils.setBaseEqual(set_a: Set | Alias, set_b: Set | Alias) bool[source]#

Checks if two sets are equal considering aliases as equal as well.

Parameters:
set_aSet | Alias
set_bSet | Alias
Returns:
bool

Examples

>>> import gamspy as gp
>>> m = gp.Container()
>>> i = gp.Set(m, "i")
>>> j = gp.Set(m, "j")
>>> gp.utils.setBaseEqual(i, j)
False
>>> k = gp.Alias(m, "k", i)
>>> gp.utils.setBaseEqual(k, i)
True