utils#

gamspy.utils.getInstalledSolvers()[source]#

Returns the list of installed solvers

Returns:
List[str]
Raises:
ModuleNotFoundError

In case gamspy_base is not installed.

Return type:

list[str]

Examples

>>> import gamspy.utils as utils
>>> installed_solvers = utils.getInstalledSolvers()
gamspy.utils.getAvailableSolvers()[source]#

Returns all available solvers that can be installed.

Returns:
List[str]
Raises:
ModuleNotFoundError

In case gamspy_base is not installed.

Return type:

list[str]

Examples

>>> import gamspy.utils as utils
>>> available_solvers = utils.getAvailableSolvers()
gamspy.utils.checkAllSame(iterable1, iterable2)[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
Parameters:
  • iterable1 (Sequence) –

  • iterable2 (Sequence) –

Return type:

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.isin(symbol, sequence)[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
Parameters:

sequence (Sequence) –

Return type:

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