Skip to main content

trivial_constraint

class Constraint

Constraint(name: 'str', condition: 'subs_expr.ConstraintCondition', forall: 'list[tuple[subs_expr.Element, subs_expr.SubstitutableCondition]]')


class InstanceData

Instance Data class

The constructor provides type validation and conversion from user's input to valid instance data type.

Attributes

  • tensor_data(dict[str, numpy.ndarray]) : tensor value of Placheolder. The key is uuid of the corresponding Placheolder.
  • jagged_data(dict[str, list]) : jagged array value of JaggedArray. The key is uuid of the corresponding JaggedArray.
  • fixed_variables(dict[str, dict[tuple[int, ...], float]]) : fixed variable values.
  • indices(dict[str, int]) : value of Element. The attribute is changing in compile process.

__init__ (self, instance_data, fixed_vars, ph_names, indices) -> -

Parameters

  • instance_data(dict) : user input instance_data.
  • fixed_vars(dict) : user input fixed_variables.
  • ph_vars(list[name]) : Placeholder list include user defined model. This is used for validation.
  • indices(typ.Optional[dict]) : value of each Elements. Defaults to None.

Raises

  • ValueError: user's input is invalid.

get_length (self, name, subscripts, axis) -> -

get_value (self, uuid, subscripts) -> -


class VariableMap

VarialeMap

This class is used to manage the mapping between the label and the index of the decision variable.

Attributes

  • var_map(dict[str, dict[tuple[int, ...], int]]) : label, subscripts -> index (int)
  • var_num(int) : number of variables
  • integer_bound(dict[str, dict[tuple[int, ...], IntegerBound]]) : bounds of integer decision variables.

add_cont_variable (self, label, subscripts, lower, upper) -> -

Add an integer variable to the variable map.

add_int_variable (self, label, subscripts, lower, upper) -> -

Add an integer variable to the variable map.

add_variable (self, label, subscripts) -> int

Add a variable to the variable map.

Parameters

  • label(str) : label of the variable
  • subscripts(tuple[int, ...]) : subscripts of the variable

Returns

  • int : index of the variable in the variable map

from_serializable (data) -> -

to_serializable (self) -> dict

Convert to a serializable object.

Returns

  • dict : serializable object

Examples

varmap = VariableMap()
varmap.add_variable("x", (0, 0))
varmap.add_variable("x", (0, 1))
varmap.to_serializable()
# {
# "class": "VariableMap",
# "var_map": {
# "x": {
# "subscripts": [
# [0, 0],
# [0, 1]
# ],
# "index": [0, 1]
# }
# },
# "var_num": 2,
# "integer_bound": {}
# }

check_trivial_constraint (condition) -> typ.Optional[ tuple[subs_expr.DecisionVariable, list[subs_expr.SubstitutableExpr], subs_expr.SubstitutableExpr]]

Check if the condition is trivially solvable.

If the condition is trivially solvable, return the variable, subscripts, and the fixed value. Otherwise, return None.

Parameters

  • condition(subs_expr.ConstraintCondition) : The condition to check.

Returns

  • typ.Optional[ tuple[subs_expr.DecisionVariable, list[subs_expr.SubstitutableExpr], subs_expr.SubstitutableExpr]] : The variable, subscripts, and the fixed value if the condition is trivially solvable.

convert_to_fixed_vars (constraint, data) -> -


expand_forall (forall, data) -> -


has_deci_var (expr) -> -