constants
File containing shared constants used across the package.
Classes:
Name | Description |
---|---|
Config |
Configuration options that apply to the entire library. |
ConstraintSense |
|
ObjSense |
|
PyoframeError |
|
Solver |
|
UnmatchedStrategy |
|
VType |
|
Attributes:
Name | Type | Description |
---|---|---|
COEF_KEY |
|
|
CONSTRAINT_KEY |
|
|
CONST_TERM |
|
|
DUAL_KEY |
|
|
KEY_TYPE |
|
|
ObjSenseValue |
|
|
QUAD_VAR_KEY |
|
|
RESERVED_COL_KEYS |
|
|
SOLUTION_KEY |
|
|
SUPPORTED_SOLVERS |
|
|
SUPPORTED_SOLVER_TYPES |
|
|
VAR_KEY |
|
|
VTypeValue |
|
COEF_KEY = '__coeff'
module-attribute
CONSTRAINT_KEY = '__constraint_id'
module-attribute
CONST_TERM = 0
module-attribute
DUAL_KEY = 'dual'
module-attribute
KEY_TYPE = pl.UInt32
module-attribute
ObjSenseValue = Literal['min', 'max']
module-attribute
QUAD_VAR_KEY = '__quadratic_variable_id'
module-attribute
RESERVED_COL_KEYS = (COEF_KEY, VAR_KEY, QUAD_VAR_KEY, CONSTRAINT_KEY, SOLUTION_KEY, DUAL_KEY)
module-attribute
SOLUTION_KEY = 'solution'
module-attribute
SUPPORTED_SOLVERS = [Solver('gurobi'), Solver('highs', supports_quadratics=False, supports_duals=False), Solver('ipopt', supports_integer_variables=False, supports_objective_sense=False, supports_write=False)]
module-attribute
SUPPORTED_SOLVER_TYPES = Literal['gurobi', 'highs', 'ipopt']
module-attribute
VAR_KEY = '__variable_id'
module-attribute
VTypeValue = Literal['continuous', 'binary', 'integer']
module-attribute
Config
Configuration options that apply to the entire library.
Methods:
Name | Description |
---|---|
reset_defaults |
Resets all configuration options to their default values. |
Attributes:
Name | Type | Description |
---|---|---|
default_solver |
SUPPORTED_SOLVER_TYPES | Solver | None
|
The solver to use when |
disable_unmatched_checks |
bool
|
|
enable_is_duplicated_expression_safety_check |
bool
|
|
float_to_str_precision |
Optional[int]
|
|
integer_tolerance |
float
|
For convenience, Pyoframe returns the solution of integer and binary variables as integers not floating point values. |
print_max_line_length |
int
|
|
print_max_lines |
int
|
|
print_max_set_elements |
int
|
Number of elements to show when printing a set to the console (additional elements are replaced with ...) |
print_uses_variable_names |
bool
|
|
default_solver = None
class-attribute
instance-attribute
The solver to use when pf.Model()
is called without specifying a solver.
If default_solver is not set (None
),
Pyoframe will choose the first solver in SUPPORTED_SOLVERS that doesn't produce an error.
There is no reason why you set the solver here instead of passing it to the Model constructor. This is mainly used for testing purposes.
disable_unmatched_checks = False
class-attribute
instance-attribute
enable_is_duplicated_expression_safety_check = False
class-attribute
instance-attribute
float_to_str_precision = 5
class-attribute
instance-attribute
integer_tolerance = 1e-08
class-attribute
instance-attribute
For convenience, Pyoframe returns the solution of integer and binary variables as integers not floating point values. To do so, Pyoframe must convert the solver-provided floating point values to integers. To avoid unexpected rounding errors, Pyoframe uses this tolerance to check that the floating point result is an integer as expected. Overly tight tolerances can trigger unexpected errors. Setting the tolerance to zero disables the check.
print_max_line_length = 80
class-attribute
instance-attribute
print_max_lines = 15
class-attribute
instance-attribute
print_max_set_elements = 50
class-attribute
instance-attribute
Number of elements to show when printing a set to the console (additional elements are replaced with ...)
print_uses_variable_names = True
class-attribute
instance-attribute
reset_defaults()
classmethod
ConstraintSense
Bases: Enum
Methods:
Name | Description |
---|---|
to_poi |
|
Attributes:
Name | Type | Description |
---|---|---|
EQ |
|
|
GE |
|
|
LE |
|
EQ = '='
class-attribute
instance-attribute
GE = '>='
class-attribute
instance-attribute
LE = '<='
class-attribute
instance-attribute
to_poi()
Source code in pyoframe/constants.py
ObjSense
PyoframeError
Bases: Exception
Solver(name, supports_integer_variables=True, supports_quadratics=True, supports_duals=True, supports_objective_sense=True, supports_write=True)
dataclass
Methods:
Name | Description |
---|---|
__repr__ |
|
check_supports_integer_variables |
|
check_supports_write |
|
Attributes:
Name | Type | Description |
---|---|---|
name |
SUPPORTED_SOLVER_TYPES
|
|
supports_duals |
bool
|
|
supports_integer_variables |
bool
|
|
supports_objective_sense |
bool
|
|
supports_quadratics |
bool
|
|
supports_write |
bool
|
|
name
instance-attribute
supports_duals = True
class-attribute
instance-attribute
supports_integer_variables = True
class-attribute
instance-attribute
supports_objective_sense = True
class-attribute
instance-attribute
supports_quadratics = True
class-attribute
instance-attribute
supports_write = True
class-attribute
instance-attribute
check_supports_integer_variables()
UnmatchedStrategy
VType
Bases: Enum
Methods:
Name | Description |
---|---|
to_poi |
|
Attributes:
Name | Type | Description |
---|---|---|
BINARY |
|
|
CONTINUOUS |
|
|
INTEGER |
|