How to use "not equal" on Constraint equations

my coding is below…


set f / bf, ac, sa, ca, tr, ra / ***these elements is actually imported from excel file.
s / 1, 2, 3, 4,/
p / a, b, c, d, e, f… / ***these elements is actually imported from excel file
f_m(f) / bf sa ca / *****these elements is also imported from excel file.
parameters grade(p) / a 2 b 2 c 10 d 15 e 15 f 16 g 10… / *** these elements is actually imported from excel file

Binary variables
X(f,s,p) ****if selected 1, otherwise 0

equations
eq6(f,s)
eq7(f,s)

eq6(f,s)…
SUM((p), X(f,s,p)) =l= 10
eq7(f,s,p)$f_m(f)… *******
X(f,“1”,p)*grade(p) X(f,“2”,p)*grade(p) *****Q(1) **here, is my question.


AboutQ(1)…
I would like to represent “not equal” as on equation.
but, error occured about . maybe, I think gams doesn’t recognize symbol over equation.
I have to represent equation that LHS value must be not equal to RHS value like above described eq7.
How can I represent that ?
Any solution?

Best regards…


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Youngki,

There is no direct way to do what you pretend. That is a kind of
constraint that requires a reformulation, and admits different types
based on what is that you want to model. I can think of a kind of
assignment problem, for which you will find specific reformulations in
the literature. If, instead, you are just comparing real variables and
want them to be different for some reason, perhaps introducing two
logically-connected inequality constraints can be a “quick and dirty”
solution.

Regards
Claudio

On Sat, Feb 8, 2014 at 9:59 PM, YOUNGKI CHOI wrote:

my coding is below…


set f / bf, ac, sa, ca, tr, ra / ***these elements is actually imported
from excel file.
s / 1, 2, 3, 4,/
p / a, b, c, d, e, f… / ***these elements is actually
imported from excel file
f_m(f) / bf sa ca / *****these elements is also imported from
excel file.
parameters grade(p) / a 2 b 2 c 10 d 15 e 15 f 16 g 10… / ***
these elements is actually imported from excel file

Binary variables
X(f,s,p) ****if selected 1, otherwise 0

equations
eq6(f,s)
eq7(f,s)

eq6(f,s)…
SUM((p), X(f,s,p)) =l= 10
eq7(f,s,p)$f_m(f)… *******
X(f,“1”,p)*grade(p) X(f,“2”,p)*grade(p) *****Q(1) **here, is my
question.


AboutQ(1)…
I would like to represent “not equal” as on equation.
but, error occured about . maybe, I think gams doesn’t recognize symbol
over equation.
I have to represent equation that LHS value must be not equal to RHS value
like above described eq7.
How can I represent that ?
Any solution?

Best regards…


“gamsworld” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

\

Thanks Claudio, but It’s not easy…

what is a reformulation about?

Do I formulate another constraint having X.l ?

some details PLZ…

regards

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Yongki,

A reformulation means writing the original constraint you want to
write in a different way to make it easier (or feasible) for the
solving procedure. For instance, what Yan suggests is a reformulation.


X(f,“1”,p)*grade(p) X(f,“2”,p)*grade(p) transformed into ( X1 - X2
) * (X1 - X2) =G= tol (e.g., 0.0001);

Another reformulations are possible and which one yields better
results is highly dependent on the problem structure.
For example, you can use a binary variable to denote if the product
X(f,“1”,p)*grade(p) is bigger or smaller than the product
X(f,“2”,p)*grade(p) and introduce two constraints, i.e. (this assumes
a positive value for this)

(X(f,“1”,p)*grade(p) =G= X(f,“2”,p)*grade(p)*binary(f,p) and
X(f,“2”,p)*grade(p)=G=X(f,“1”,p)grade(p)(1-binary(f,p))

binary(f,p) would be 1 for solutions where the product for ‘1’ is
larger than that for ‘2’, and zero for the other case.

Again, there should be several ways, your best bet is to check the
literature for formulations of similar problems.

Regards!
Claudio

On Mon, Feb 10, 2014 at 10:48 PM, Yan Ren wrote:

hello Yongki,

  • X(f,“1”,p)*grade(p) X(f,“2”,p)*grade(p) *****Q(1) *here, is my question.
    to formulate the in equation, you may try this way :

( X1 - X2 ) * (X1 - X2) =G= tol (e.g., 0.0001);

when equation above holds, X(f,“1”,p) and X(f,“2”,p) is not be equal, and the difference between them depends on the tolerance set at RHS.

HTH,


发件人:YOUNGKI CHOI
发送日期:2014-02-09 18:20:04
收件人:gamsworld
抄送:
主题:How to use “not equal” on Constraint equations

my coding is below…


set f / bf, ac, sa, ca, tr, ra / ***these elements is actually imported
from excel file.
s / 1, 2, 3, 4,/
p / a, b, c, d, e, f… / ***these elements is actually
imported from excel file
f_m(f) / bf sa ca / *****these elements is also imported from
excel file.
parameters grade(p) / a 2 b 2 c 10 d 15 e 15 f 16 g 10… / ***
these elements is actually imported from excel file

Binary variables
X(f,s,p) ****if selected 1, otherwise 0

equations
eq6(f,s)
eq7(f,s)

eq6(f,s)…
SUM((p), X(f,s,p)) =l= 10
*eq7(f,s,p)$f_m(f)… ********

  • X(f,“1”,p)*grade(p) X(f,“2”,p)*grade(p) *****Q(1) *here, is my
    question.


AboutQ(1)…
I would like to represent “not equal” as on equation.
but, error occured about . maybe, I think gams doesn’t recognize symbol
over equation.
I have to represent equation that LHS value must be not equal to RHS value
like above described eq7.
How can I represent that ?
Any solution?

Best regards…


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Yan Ren
R&D Engineer
Process Integration Limited


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

\

I appreciate your solution, Ryan and claudio!
Actually, I have only done LP therefore, I didn’t think of NLP.
I nee to apply this way. Thanks a lot.

Regards

\