> I came across a curious quirk in the use of the new suffixes in GMPL: > how a constraint is formed leads to non-intuitive dual results. > > This model: > # Simple Model 1 > var x1 >= 0; > var x2 >= 0; > var s1 >= 0; > var s2 >= 0; > > s.t. constraint1 : 1.0 = 0.1*x1 + x2 + s1; > s.t. constraint2 : 1.0 = x1 + 0.2*x2 + s2; > minimize obj: -x1 - x2; > > solve; > > display constraint1.dual; > display constraint2.dual; > > end; > > displays the two duals as > constraint1.dual = 0.816326530612245 > constraint2.dual = 0.918367346938776 > > But changing how constraint1 and constraint2 are written to: > s.t. constraint1 : 0.1*x1 + x2 + s1 = 1.0; > s.t. constraint2 : x1 + 0.2*x2 + s2 = 1.0; > > displays the two duals as > constraint1.dual = -0.816326530612245 > constraint2.dual = -0.918367346938776 > > Using the "--wlp" option, it's easy to see what is occuring. In the > first case, the "wlp" output is: > \* Problem: simple *\ > > Minimize > obj: - x1 - x2 > > Subject To > constraint1: - 0.1 x1 - x2 - s1 = -1 > constraint2: - x1 - 0.2 x2 - s2 = -1 > > End > > and in the second case the "wlp" output is: > > \* Problem: simple *\ > > Minimize > obj: - x1 - x2 > > Subject To > constraint1: + 0.1 x1 + x2 + s1 = 1 > constraint2: + x1 + 0.2 x2 + s2 = 1 > > End > > By switching around the terms on the "=" sign, GMPL reversed the signs > of all of the coefficients. Which reversed the signs on the duals. > > I'm not a fan of the changing of the sign when I plan to use the duals > for calculations later on; it leads to somewhat random behavior, and > makes using the new suffixes a little scary for bigger models when it > is not easy to know the correct sign for each constraint. Is there > really a need to change the signs? I would hope this could be turned > off. >
Do you agree that a*x = b and 2*a*x = 2*b are different constraints (though they define identical feasible regions)? Constraints a*x = b and -a*x = -b are different for the same reason. In glpk reduced costs are Lagrange multipliers defined by the dual equalities, so there is no "freedom" to change their signs. The common rule used in glpk is the following: reduced cost r is a change in the objective function z per unit change in corresponding (auxiliary or structural) variable x, that is, dz = r * dx, independently on whether z is minimized or maximized. _______________________________________________ Help-glpk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-glpk
