Closed WaqasSwati1 closed 2 years ago
You are passing a generator that returns expressions to the Constraint()
definition. Pyomo interprets generators as indexing sets. The correct way to declare an indexed constraint is with a rule:
def c1_rule(m, ub):
return sum(m.fi[ub, u] for ub in m.nf for u in m.ns * m.Dcpu[ub] for ub in m.nf) <= m.Ccpu[u] for u in m.ns) * m.acp[ub]
model.c1 = Constraint(model.nf, rule=c1_rule)
or more concisely:
@model.Constraint(model.nf)
def c1(m, ub):
return sum(m.fi[ub, u] for ub in m.nf for u in m.ns * m.Dcpu[ub] for ub in m.nf) <= m.Ccpu[u] for u in m.ns) * m.acp[ub]
For future reference, GitHub issues are for reporting bugs in Pyomo and requesting new features. Please direct support questions to the Pyomo forum or StackOverflow (see Getting Help).
I am trying to write the following constraint in pyomo:
The description is as follows:
ū ∈ Nf=Nodes from a set Gf
u ∈ Ns=Nodes from a set Gs
Φf=binary variable indicating 1 if the node ū from Nf can be deployed on u from Ns, otherwise 0.
Df cpu ū = demand (CPU parameter) of node ū.
a cpu u = available ratio of node u (ratio = capacity-demand).
C cpu u = capacity (CPU parameter) of node u.
For a long, I am receiving different errors and I am unable to locate the problem.
Currently, I am getting the 'TypeError: unhashable type: 'InequalityExpression' ' error.
Please help me to get out of this.
Regards