dual variables and extreme rays

54 views
Skip to first unread message

Fabrizio

unread,
Dec 12, 2011, 6:57:17 AM12/12/11
to coopr forum
Hi,

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

Watson, Jean-paul

unread,
Dec 18, 2011, 9:33:23 PM12/18/11
to coopr...@googlegroups.com
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

Fabrizio

unread,
Dec 20, 2011, 11:14:47 AM12/20/11
to coopr forum
Hi Jean,

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
>

Reply all
Reply to author
Forward
0 new messages