|
|
@ -30,16 +30,12 @@ def _round(obj: Any) -> Any:
|
|
|
|
return tuple([_round(v) for v in obj])
|
|
|
|
return tuple([_round(v) for v in obj])
|
|
|
|
if isinstance(obj, list):
|
|
|
|
if isinstance(obj, list):
|
|
|
|
return [_round(v) for v in obj]
|
|
|
|
return [_round(v) for v in obj]
|
|
|
|
|
|
|
|
if isinstance(obj, dict):
|
|
|
|
|
|
|
|
return {key: _round(value) for (key, value) in obj.items()}
|
|
|
|
if isinstance(obj, VariableFeatures):
|
|
|
|
if isinstance(obj, VariableFeatures):
|
|
|
|
obj.reduced_costs = _round(obj.reduced_costs)
|
|
|
|
obj.__dict__ = _round(obj.__dict__)
|
|
|
|
obj.sa_obj_up = _round(obj.sa_obj_up)
|
|
|
|
if isinstance(obj, ConstraintFeatures):
|
|
|
|
obj.sa_obj_down = _round(obj.sa_obj_down)
|
|
|
|
obj.__dict__ = _round(obj.__dict__)
|
|
|
|
obj.sa_lb_up = _round(obj.sa_lb_up)
|
|
|
|
|
|
|
|
obj.sa_lb_down = _round(obj.sa_lb_down)
|
|
|
|
|
|
|
|
obj.sa_ub_up = _round(obj.sa_ub_up)
|
|
|
|
|
|
|
|
obj.sa_ub_down = _round(obj.sa_ub_down)
|
|
|
|
|
|
|
|
obj.values = _round(obj.values)
|
|
|
|
|
|
|
|
obj.alvarez_2017 = _round(obj.alvarez_2017)
|
|
|
|
|
|
|
|
return obj
|
|
|
|
return obj
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -110,18 +106,6 @@ def run_basic_usage_tests(solver: InternalSolver) -> None:
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert_equals(
|
|
|
|
|
|
|
|
_round_constraints(solver.get_constraints_old()),
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"eq_capacity": Constraint(
|
|
|
|
|
|
|
|
lazy=False,
|
|
|
|
|
|
|
|
lhs={"x[0]": 23.0, "x[1]": 26.0, "x[2]": 20.0, "x[3]": 18.0, "z": -1.0},
|
|
|
|
|
|
|
|
rhs=0.0,
|
|
|
|
|
|
|
|
sense="=",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Solve linear programming relaxation
|
|
|
|
# Solve linear programming relaxation
|
|
|
|
lp_stats = solver.solve_lp()
|
|
|
|
lp_stats = solver.solve_lp()
|
|
|
|
assert not solver.is_infeasible()
|
|
|
|
assert not solver.is_infeasible()
|
|
|
@ -154,28 +138,17 @@ def run_basic_usage_tests(solver: InternalSolver) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
# Fetch constraints (after-lp)
|
|
|
|
# Fetch constraints (after-lp)
|
|
|
|
assert_equals(
|
|
|
|
assert_equals(
|
|
|
|
_round_constraints(solver.get_constraints_old()),
|
|
|
|
_round(solver.get_constraints(with_static=False)),
|
|
|
|
_remove_unsupported_constr_attrs(
|
|
|
|
_filter_attrs(
|
|
|
|
solver,
|
|
|
|
solver.get_constraint_attrs(),
|
|
|
|
{
|
|
|
|
ConstraintFeatures(
|
|
|
|
"eq_capacity": Constraint(
|
|
|
|
basis_status=("N",),
|
|
|
|
basis_status="N",
|
|
|
|
dual_values=(13.538462,),
|
|
|
|
dual_value=13.538462,
|
|
|
|
names=("eq_capacity",),
|
|
|
|
lazy=False,
|
|
|
|
sa_rhs_down=(-24.0,),
|
|
|
|
lhs={
|
|
|
|
sa_rhs_up=(2.0,),
|
|
|
|
"x[0]": 23.0,
|
|
|
|
slacks=(0.0,),
|
|
|
|
"x[1]": 26.0,
|
|
|
|
),
|
|
|
|
"x[2]": 20.0,
|
|
|
|
|
|
|
|
"x[3]": 18.0,
|
|
|
|
|
|
|
|
"z": -1.0,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
rhs=0.0,
|
|
|
|
|
|
|
|
sa_rhs_down=-24.0,
|
|
|
|
|
|
|
|
sa_rhs_up=1.9999999999999987,
|
|
|
|
|
|
|
|
sense="=",
|
|
|
|
|
|
|
|
slack=0.0,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|