I’m using a _rule_function to build constraints.
Constraint(model.S, model.T, model.sc, rule=_rule_function, doc=’RestrictionX’)
In it, I want to return multiple constraints based on parameters of the model.
The rule-function loops over a list of lists, for each of the inner lists, I want to create one individual constraint. At the end of the loop I append the constraint to an array and have the rule-function return that array of constraints.
Is this procedure possible in pyomo 5.7?
I think trying to return a tuple of many constraints may cause the problem.
I tried returning a tuple of constraints and an array of constraints.
Both didn’t work out.
In some cases of parameters, I addend a placeholder constraint with
placeholder_constraint = Constraint.Skip
area_constraints.append(placeholder_constraint)
The error is currently:
ERROR: Constructing component ‘cons_area_at_site’ from data=None failed:
TypeError: Cannot treat the value ‘(1000,)’ as a constant because it has
unknown type ‘tuple’
ERROR: Constructing component ‘cons_area_at_site’ from data=None failed:
TypeError: Cannot treat the value ‘(1000,)’ as a constant because it has unknown type ‘tuple’
Samuel Bolender is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.