Miscellaneous¶
About This Package¶
This package has various miscellaneuos helper functions and modules
Helper Functions¶
Accumulation of general helper functions
-
games.misc.helpers.
powerset
(iterable: Iterable) → List[tuple]¶ Returns a power set from the given iterable.
- Parameters
iterable (Iterable) – Iterable from which to take the power set from.
- Returns
A list of tuples containing subsets of the given Iterable.
- Return type
List[tuple]
-
games.misc.helpers.
verify_player_list
(game: games.types.game.Game) → None¶ Check that player list is nonempty and indexed from 0 to N.
- Parameters
game (Game) – Game to check.
- Raises
ValueError – If the player list is empty or not indexed properly.
Optimization Wrappers¶
Module for wrapping optimization solvers for use in the game package.
-
class
games.misc.solver.
SolverWrapper
(solver: str, progress: bool)¶ Wrapper for solving Convex Programs.
- Parameters
-
check_solver
(solver: str) → None¶ check if solver is supported and perform some necessary setup.
- Parameters
solver (str) – Which solver to use.
- Raises
ImportError – If solver given is not an implemented solver.
-
lp
(c: numpy.ndarray, G: numpy.ndarray, h: numpy.ndarray, A: numpy.ndarray, b: numpy.ndarray) → Optional[Dict[str, Any]]¶ solver for LP. Form is min c^T x subject to G x <= h , A x = b.
- Parameters
c (np.ndarray) – Objective function.
G (np.ndarray) – Linear inequality constraint.
h (np.ndarray) – Linear inequality constraint.
A (np.ndarray) – Linear equality constraint.
b (np.ndarray) – Linear equality constraint.
- Returns
If not returnall, return {‘min’: minimum of objective, ‘argmin’: value in which the minimum is obtained.}.
- Return type
Optional[Dict[str, Any]]
- Raises
ImportError – If specified solver is not an implemented LP solver.
-
games.misc.solver.
lp
(solver: str, c: numpy.ndarray, G: numpy.ndarray, h: numpy.ndarray, A: numpy.ndarray = None, b: numpy.ndarray = None, progress: bool = False) → Dict[str, Any]¶ lp solver of the standard form: min c^T x subject to G x <= h , A x = b.
- Parameters
solver (str) – which solver to use for solving the linear program.
c (np.ndarray) – Objective function.
G (np.ndarray) – Linear inequality constraint.
h (np.ndarray) – Linear inequality constraint.
A (np.ndarray, optional) – Linear equality constraint.
b (np.ndarray, optional) – Linear equality constraint.
progress (bool, optional) – Toggle to show progress of optimization solver.
- Returns
{‘min’: minimum of objective, ‘argmin’: value in which the minimum is obtained.}
- Return type
Dict[str, Any]