considering a script with an .lp like the (linear) knapsack problem, i
tryed to retrieve the dual of a constraints by setting
--------------
from coopr.pyomo import *
from coopr.opt import *
def weight_rule(model):
return sum(model.w[i]*model.x[i] for i in model.ITEMS) <=
model.limit
model.weight = Constraint()
# Create the model instance
instance = model.create("knapsack.dat")
#
# Setup the optimizer
solver = SolverFactory("cplex")
#
# Optimize
results = opt.solve(instance, suffixes=['rc', 'dual'])
#solver_manager = SolverManagerFactory("serial")
#results = solve_all_instances(solver_manager, solver, instance,
suffixes=['rc', 'dual'])
instance.load(results)
print "%f" % instance.weight.dual
------
but it says that the object constraint has no attribute dual. how
should i modify the code to get the dual of the weight cns?
Moreover since this is the first step towards a benders decomposition
for MIP problem, what about the extreme rays in the case of primal
infeasibility? The issue seems not so easy even using the cplex python
direct api in that if the presolve detects the infeasibility the
extreme rays are not correctly reported,
https://www-304.ibm.com/support/docview.wss?uid=swg21400058
Shoud then one necessarily solve the "infeasibility associated prob"
such as and getting the positive dual of the modified cns?
min s
AX + s <= b --- > u_rays
s,x >=0
any hint very much appreciated
regards
Fabrizio
Can you try the following:
print "%f" % instance.weight[None].dual
I believe the issue involves the fact that a Constraint is a collection of
ConstraintData objects, and the duals are attributes of ConstraintData. If
the Constraint is a singleton, the None index can be used (I think/hope)
to access the single ConstraintData object.
jpw
ok that works...i was struggling. Now i have to understan the extreme
rays issue, i vve seen the pyomo benders example, but it seems that no
infeasible sub problem is considered, or am i wrong?
Fabrizio
On 19 Dic, 03:33, "Watson, Jean-paul" <jwat...@sandia.gov> wrote:
> Hi Fabrizio,
>
> Can you try the following:
>
> print "%f" % instance.weight[None].dual
>
> I believe the issue involves the fact that a Constraint is a collection of
> ConstraintData objects, and the duals are attributes of ConstraintData. If
> the Constraint is a singleton, the None index can be used (I think/hope)
> to access the single ConstraintData object.
>
> jpw
>