sensitivity analysis issues

124 views
Skip to first unread message

vaishnavi guntupalli

unread,
Sep 13, 2022, 11:18:35 PM9/13/22
to AMPL Modeling Language
I have the following code:

reset;
option solver "cplex";
option cplex_options sensitivity;
var RO >= 0;
var CR >= 0;
maximize z: 80*RO + 460*CR;
subject to nurse: 2*RO + 5*CR <= 200;
subject to doctor: 1*RO + 2*CR <= 90;
subject to bed: 0*RO + 1*CR <= 35;
solve;
display _conname, _con.slack, _con.down, _con.current, _con.up, _con.dual;

AMPL displays all 0s for the sensitivity analysis values of constraint bed where as the expected solution is different.

Can someone help me understand why this is the case?

Thank you.

AMPL Google Group

unread,
Sep 14, 2022, 6:46:41 PM9/14/22
to AMPL Modeling Language
If you add "option show_stats 1;" at the beginning, you'll see this message:

Presolve eliminates 1 constraint.

The constraint that's being eliminated is "bed":


subject to bed: 0*RO + 1*CR <= 35;

Because the coefficient of RO is 0, this constraint is really just CR <= 35. So AMPL's presolve phase adds an upper bound of 35 on variable CR, and drops (eliminates) the constraint. As a result, the solver does not see this constraint, and hence it does not return any sensitivity information for this constraint.

To get sensitivity information for all of the constraints, turn off AMPL's presolve by adding "option presolve 0;" prior to "solve". Then you will get results for all of the constraints:

: _conname _con.slack _con.down _con.current _con.up _con.dual    :=
1   nurse      0         175         200         215      40
2   doctor     7.5        82.5        90       1e+20       0
3   bed        0          20          35          40     260


--
Robert Fourer
am...@googlegroups.com
{#HS:2008874759-111910#}

vaishnavi guntupalli

unread,
Sep 17, 2022, 9:09:52 AM9/17/22
to am...@googlegroups.com
Thank you so much. 
This solved my issue.

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-2008874759-5966743958-1663195597-1098242638%40helpscout.net.
Reply all
Reply to author
Forward
0 new messages