Excluding Zeroes

24 views
Skip to first unread message

Bruno Hannud

unread,
Feb 7, 2016, 2:38:03 PM2/7/16
to gamsworld
Dear all.

I have an equation which looks like this:

eq1.. R=E= a(i)/b(i);

And an objective function:

obj.. z =E= sum(i, a(i)/b(i));

Is there a way to sum only the terms with b(i) not equal to zero? I tried using conditionals on the R equation, but when I try to run I get an 

***Error 52 Endogenous $-control not allowed.

Any help is appreciated.

Tks

Bruno

Renger van Nieuwkoop

unread,
Feb 7, 2016, 3:59:10 PM2/7/16
to gams...@googlegroups.com

Hi Bruno

You could define a third variable m(i) and an equation eq_m(i):

 

Eq_m(i).. m(i)*b(i) =E= a(i);

 

Obj.. z= E= sum(I, m(i));

Cheers

Renger

--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Bruno Hannud

unread,
Feb 7, 2016, 4:53:29 PM2/7/16
to gamsworld
Tks a lot for your reply Renger.

I have a query. If b(i)=0, isn't m(i) undefined? Or will GAMS automatically attribute the value zero to m(i)?

Rgds

Bruno

Bruno Hannud

unread,
Feb 7, 2016, 4:53:32 PM2/7/16
to gamsworld
Renger, I think I made a mistake.

If b(i)=0, the equation might be undefined (if a(i)=0) or will have no solution (if a(i) <>0).

Rgds

Bruno

On Sunday, February 7, 2016 at 6:59:10 PM UTC-2, Renger van Nieuwkoop wrote:

Claudio Delpino

unread,
Feb 15, 2016, 3:58:39 AM2/15/16
to gams...@googlegroups.com

Hi Bruno: You need to think what values of b are allowed (feasible). If you are asking for a(i)/b(i) to be equal to a scalar (R), then b cannot be zero for any index. If the solver takes you there, you can use a small artificial bound (b.lo(i) =1E-6).

If you want different equations in the model according to the value of variables (if b=0 is allowed, and eq1 doesn't apply to those indexes ) , that is called "disjunctive programming", look it up. 

Best regards!
Claudio

--

Bruno Hannud

unread,
Feb 15, 2016, 5:35:38 AM2/15/16
to gams...@googlegroups.com
Thanks Claudio.


Sent with Unibox

You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/8fxMcDznTaY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gamsworld+...@googlegroups.com.

Bruno Hannud

unread,
Feb 15, 2016, 5:35:42 AM2/15/16
to gams...@googlegroups.com
Dear Claudio, in my model, if b(i)=0, I attribute a(i)/b(i) = 0, otherwise, the answer is the normal one. Does this still classify in disjunctive programming?

Thanks.

Bruno


Sent with Unibox

On Feb 14, 2016, at 8:11 PM, Claudio Delpino <clade...@gmail.com> wrote:

You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/8fxMcDznTaY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gamsworld+...@googlegroups.com.

Claudio Delpino

unread,
Feb 15, 2016, 10:25:55 AM2/15/16
to gams...@googlegroups.com
Bruno: I'm not an expert on that approach, someone else around here can help you better, but: 

Is b(i) a parameter or a variable ? 

If it is a variable: I read from your last mail that b(i)=0 => a(i)=0. If that's the case, I guess you'll be fine (if the model is not large) introducing binary variables and use something like a "big M" formulation. Like I said before, I'm not an expert. If I remember correctly, EMP has some facilities for that kind of reformulations, so perhaps lloking through its manual will give you some ideas. 

Best Regards
Claudio

Bruno Hannud

unread,
Feb 15, 2016, 10:52:38 AM2/15/16
to gams...@googlegroups.com
Claudio thanks for your answer. In my problem:

b(i) is a variable.

If b(i) = 0, a(i) is not necessarily zero, but I must impose that a(i)/b(i) =0

meaning that in the case b(i)=0, we exlude these values of a(i)/b(i) from the sum(i, a(i)/b(i)).

Bruno

Sent with Unibox
Reply all
Reply to author
Forward
0 new messages