[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Help-glpk] The "dual" suffix and sensitivity to how a constraint is
From: |
Meketon, Marc |
Subject: |
RE: [Help-glpk] The "dual" suffix and sensitivity to how a constraint is expressed in GMPL |
Date: |
Tue, 28 Dec 2010 16:20:21 -0600 |
Xypron,
I thank you for your very speedy reply. And I appreciate your explanation -
it's very clear. I do wonder if a special case should be made when only one
side has variables. I have somewhat mixed feelings about that - special cases
in general are confusing, but superfluous sign reversals are confusing as well.
Indeed, I did change the constraints to put all the constants on the right-hand
side.
Maybe your update of the wiki should go a little further and give a clearer
explanation. In addition to saying:
"The duals will be calculated based on the standard form of the constraints."
Maybe your should add on the sentences:
For example, the GMPL constraint "1 = c * y" will be transformed into "-c * y =
-1", and the dual value generated will be the negative of the value if the
constraint was written as "c * y = 1". Generally, it is good idea to put the
constant term on the right-hand-side when obtaining duals are important for
subsequent non-GLPK related calculations.
-Marc
-----Original Message-----
From: glpk xypron [mailto:address@hidden
Sent: Tuesday, December 28, 2010 5:00 PM
To: Meketon, Marc; address@hidden
Subject: Re: [Help-glpk] The "dual" suffix and sensitivity to how a constraint
is expressed in GMPL
Hello Marc,
in the general case a constraint may have the form:
a + sum b[i] x[i] <=> c + sum d[i] x[i];
Now all columns have to be moved to the left and all constants to the right
giving you:
sum (b[i]-d[i]) x[i] <=> c - a;
Giving your special case a special treatment might create results that are not
intuitive in a different context.
Why do you not always write the columns on the left hand side and the constants
on the right hand side?
The code in question is in glpk-4.45/src/glpmpl03.c, function take_member_con,
where you can find the transformation rules:
/* constraint a * x + b >= c * y + d is transformed to the
standard form a * x - c * y >= d - b */
/* constraint a * x + b <= c * y + d is transformed to the
standard form a * x - c * y <= d - b */
/* constraint a * x + b = c * y + d is transformed to the
standard form a * x - c * y = d - b */
/* ranged constraint c <= a * x + b <= d is transformed to
the standard form c - b <= a * x <= d - b */
I have updated
http://en.wikibooks.org/wiki/GLPK/Steps_of_GMPL_File_Processing#Model_generation
Best regards
Xypron
-------- Original-Nachricht --------
> Datum: Tue, 28 Dec 2010 15:22:19 -0600
> Betreff: [Help-glpk] The "dual" suffix and sensitivity to how a
> constraint is expressed in GMPL
> 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.
>
> -Marc
>
>
>
>
> ________________________________
> This e-mail and any attachments may be confidential or legally privileged.
> If you received this message in error or are not the intended
> recipient, you should destroy the e-mail message and any attachments
> or copies, and you are prohibited from retaining, distributing,
> disclosing or using any information contained herein. Please inform us
> of the erroneous delivery by return e-mail. Thank you for your cooperation.
--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
----------------------------------------------------------------------------
This e-mail and any attachments may be confidential or legally privileged. If
you received this message in error or are not the intended recipient, you
should destroy the e-mail message and any attachments or copies, and you are
prohibited from retaining, distributing, disclosing or using any information
contained herein. Please inform us of the erroneous delivery by return e-mail.
Thank you for your cooperation.
----------------------------------------------------------------------------
This e-mail and any attachments may be confidential or legally privileged. If
you received this message in error or are not the intended recipient, you
should destroy the e-mail message and any attachments or copies, and you are
prohibited from retaining, distributing, disclosing or using any information
contained herein. Please inform us of the erroneous delivery by return e-mail.
Thank you for your cooperation.