Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
\
Hi,
I think you need to declare it as binary variable first, then use what ever is you conditions, i.e in GAMS
Binary Variable X(i,j) some descriptions;
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
Sincerely
~Krish
\
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) = 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j) wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j) > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
This is an optimization model. My model has Y(i,j) as an output. Then
I want to define this binary variable X to use it in another
constraint so as to have some certain Y(i,j)s.
On Aug 25, 7:07 pm, “shahin.gela...@gmail.com”
wrote:
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j)> > > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Ali,
If the objective function does not push X in one direction you need
more
than one constraint.
To keep things simpler forget about the indices and have the example
if (Y1=1 or Y2=1) then X=1 else X=0.
You can write the following (this may not be the unique or best way
for
your problem, but works)
-
Y1 in {0,1}, Y2 in {0,1}, X in [0,1]
-
X= Y1
which ensures that X=1 if Y1=1
if Y1=0 the constraint becomes redundant X>=0
-
X>= Y2
which ensures that X=1 if Y2=1
if Y2=0 the constraint becomes redundant X>=0
In general there are well-established techniques to write this type of
constraints. Have a look at the following links to see how we used
such
techniques in problems involving reaction networks
http://dx.doi.org/10.1186/1752-0509-5-107
http://dx.doi.org/10.1371/journal.pcbi.1000591
http://dx.doi.org/10.1016/j.combustflame.2008.03.004
We cite some of the old work dealing with these techniques.
On Aug 25, 11:42 am, “/\ l_ !” wrote:
This is an optimization model. My model has Y(i,j) as an output. Then
I want to define this binary variable X to use it in another
constraint so as to have some certain Y(i,j)s.
On Aug 25, 7:07 pm, “shahin.gela...@gmail.com”
wrote:
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j)>> > > > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Thank You Alexander
But I must mention that Y is an integer variable and can be
0,1,2,3,… so a lot of constraints above cant be applied to my
model.
Also thanks to you shahin.
On Aug 25, 7:49 pm, Alexander wrote:
Ali,
If the objective function does not push X in one direction you need
more
than one constraint.
To keep things simpler forget about the indices and have the example
if (Y1=1 or Y2=1) then X=1 else X=0.
You can write the following (this may not be the unique or best way
for
your problem, but works)
-
Y1 in {0,1}, Y2 in {0,1}, X in [0,1]
-
X > which ensures that X=0 if both Y1 and Y2 are 0.
if either Y1=1 or Y2=1 the constraint becomes redundant X > if both Y1=1 and Y2=1 the constraint becomes redundant X >
-
X>= Y1
which ensures that X=1 if Y1=1
if Y1=0 the constraint becomes redundant X>=0
-
X>= Y2
which ensures that X=1 if Y2=1
if Y2=0 the constraint becomes redundant X>=0
In general there are well-established techniques to write this type of
constraints. Have a look at the following links to see how we used
such
techniques in problems involving reaction networkshttp://dx.doi.org/10.1186/1752-0509-5-107http://dx.doi.org/10.1371/journal.pcbi.1000591http://dx.doi.org/10.1016/j.combustflame.2008.03.004
We cite some of the old work dealing with these techniques.
On Aug 25, 11:42 am, “/\ l_ !” wrote:
This is an optimization model. My model has Y(i,j) as an output. Then
I want to define this binary variable X to use it in another
constraint so as to have some certain Y(i,j)s.
On Aug 25, 7:07 pm, “shahin.gela...@gmail.com”
wrote:
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j)>>> > > > > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
Well, perhaps I understood it wrong but I guess Y is integer non
necessarily binary.
Okay, I was extremely busy and brain was not working when I wrote the
last post.
There is indeed a linear way to do that but of course nut of numerical
interest.
introduce g(i,j)as binary variable, f(i,j) as binary and M a big
constant.
Y(i,j) = g(i,j)
f(i,j) >= g(j,i)
x(i,j) = f(i,j)
I hope I haven’t done any mistake here. otherwise you will find it.
On Aug 25, 5:49 pm, Alexander wrote:
Ali,
If the objective function does not push X in one direction you need
more
than one constraint.
To keep things simpler forget about the indices and have the example
if (Y1=1 or Y2=1) then X=1 else X=0.
You can write the following (this may not be the unique or best way
for
your problem, but works)
-
Y1 in {0,1}, Y2 in {0,1}, X in [0,1]
-
X > which ensures that X=0 if both Y1 and Y2 are 0.
if either Y1=1 or Y2=1 the constraint becomes redundant X > if both Y1=1 and Y2=1 the constraint becomes redundant X >
-
X>= Y1
which ensures that X=1 if Y1=1
if Y1=0 the constraint becomes redundant X>=0
-
X>= Y2
which ensures that X=1 if Y2=1
if Y2=0 the constraint becomes redundant X>=0
In general there are well-established techniques to write this type of
constraints. Have a look at the following links to see how we used
such
techniques in problems involving reaction networkshttp://dx.doi.org/10.1186/1752-0509-5-107http://dx.doi.org/10.1371/journal.pcbi.1000591http://dx.doi.org/10.1016/j.combustflame.2008.03.004
We cite some of the old work dealing with these techniques.
On Aug 25, 11:42 am, “/\ l_ !” wrote:
This is an optimization model. My model has Y(i,j) as an output. Then
I want to define this binary variable X to use it in another
constraint so as to have some certain Y(i,j)s.
On Aug 25, 7:07 pm, “shahin.gela...@gmail.com”
wrote:
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j)>>> > > > > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
thank you but there is still a problem here
in case both Y(i,j) and Y(j,i) are 0, in the first two constraints
that you have written g(i,j) and g(j,i) can both be either 1 or 0. for
example considering g(i,j)=1 the first constraint will be 0 wrote:
Well, perhaps I understood it wrong but I guess Y is integer non
necessarily binary.
Okay, I was extremely busy and brain was not working when I wrote the
last post.
There is indeed a linear way to do that but of course nut of numerical
interest.
introduce g(i,j)as binary variable, f(i,j) as binary and M a big
constant.
Y(i,j) > Y(j,i) > f(i,j) >= g(i,j)
f(i,j) >= g(j,i)
x(i,j) = f(i,j)
I hope I haven’t done any mistake here. otherwise you will find it.
On Aug 25, 5:49 pm, Alexander wrote:
Ali,
If the objective function does not push X in one direction you need
more
than one constraint.
To keep things simpler forget about the indices and have the example
if (Y1=1 or Y2=1) then X=1 else X=0.
You can write the following (this may not be the unique or best way
for
your problem, but works)
- Y1 in {0,1}, Y2 in {0,1}, X in [0,1]
- X> > > which ensures that X=0 if both Y1 and Y2 are 0.
if either Y1=1 or Y2=1 the constraint becomes redundant X> > > if both Y1=1 and Y2=1 the constraint becomes redundant X >
- X>= Y1
which ensures that X=1 if Y1=1
if Y1=0 the constraint becomes redundant X>=0
- X>= Y2
which ensures that X=1 if Y2=1
if Y2=0 the constraint becomes redundant X>=0
In general there are well-established techniques to write this type of
constraints. Have a look at the following links to see how we used
such
techniques in problems involving reaction networkshttp://dx.doi.org/10.1186/1752-0509-5-107http://dx.doi.org/10.1371/jo…
We cite some of the old work dealing with these techniques.
On Aug 25, 11:42 am, “/\ l_ !” wrote:
This is an optimization model. My model has Y(i,j) as an output. Then
I want to define this binary variable X to use it in another
constraint so as to have some certain Y(i,j)s.
On Aug 25, 7:07 pm, “shahin.gela...@gmail.com”
wrote:
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j)>>>> > > > > > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
my friend, if it does not make you objective better then leave it to
be any thing as long as it does not cut off part of your feasible
region.
have you ever though why most of MIP are extremely challenging for
solvers? why people designed different customized B&B rules? . Because
the know such behaviors and they just dont want to leave it to a
generic MIP solver to spend time on it blindly.
Only for very few class of problems an ideal formulation is known
which is tight and … as you wish.
Dont be that obsessive, take that and make use of it. Your feasible
region is contained here.
On Aug 26, 11:53 am, “/\ l_ !” wrote:
thank you but there is still a problem here
in case both Y(i,j) and Y(j,i) are 0, in the first two constraints
that you have written g(i,j) and g(j,i) can both be either 1 or 0. for
example considering g(i,j)=1 the first constraint will be 0 > is correct and thus we’ll have x(i,j)=1 which is wrong and it must be
0 in case Y(i,j)=Y(j,i)=0
On Aug 25, 10:24 pm, “shahin.gela...@gmail.com”
wrote:
Well, perhaps I understood it wrong but I guess Y is integer non
necessarily binary.
Okay, I was extremely busy and brain was not working when I wrote the
last post.
There is indeed a linear way to do that but of course nut of numerical
interest.
introduce g(i,j)as binary variable, f(i,j) as binary and M a big
constant.
Y(i,j) > > > Y(j,i) > > > f(i,j) >= g(i,j)
f(i,j) >= g(j,i)
x(i,j) = f(i,j)
I hope I haven’t done any mistake here. otherwise you will find it.
On Aug 25, 5:49 pm, Alexander wrote:
Ali,
If the objective function does not push X in one direction you need
more
than one constraint.
To keep things simpler forget about the indices and have the example
if (Y1=1 or Y2=1) then X=1 else X=0.
You can write the following (this may not be the unique or best way
for
your problem, but works)
- Y1 in {0,1}, Y2 in {0,1}, X in [0,1]
- X>> > > > which ensures that X=0 if both Y1 and Y2 are 0.
if either Y1=1 or Y2=1 the constraint becomes redundant X>> > > > if both Y1=1 and Y2=1 the constraint becomes redundant X >
- X>= Y1
which ensures that X=1 if Y1=1
if Y1=0 the constraint becomes redundant X>=0
- X>= Y2
which ensures that X=1 if Y2=1
if Y2=0 the constraint becomes redundant X>=0
In general there are well-established techniques to write this type of
constraints. Have a look at the following links to see how we used
such
techniques in problems involving reaction networkshttp://dx.doi.org/10.1186/1752-0509-5-107http://dx.doi.org/10.1371/jo…
We cite some of the old work dealing with these techniques.
On Aug 25, 11:42 am, “/\ l_ !” wrote:
This is an optimization model. My model has Y(i,j) as an output. Then
I want to define this binary variable X to use it in another
constraint so as to have some certain Y(i,j)s.
On Aug 25, 7:07 pm, “shahin.gela...@gmail.com”
wrote:
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j)>>>>> > > > > > > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
–
Sincerely
~Krish
\
With these constraints X(i,j) would be equal to 1 for all the Y(i,j)s.
So what’s the point of defining a binary variable if it is gonna be 1
all the time. Instead of that I could simply define it as a parameter
X(i,j)=1!
On Aug 26, 2:17 pm, “shahin.gela...@gmail.com”
wrote:
my friend, if it does not make you objective better then leave it to
be any thing as long as it does not cut off part of your feasible
region.
have you ever though why most of MIP are extremely challenging for
solvers? why people designed different customized B&B rules? . Because
the know such behaviors and they just dont want to leave it to a
generic MIP solver to spend time on it blindly.
Only for very few class of problems an ideal formulation is known
which is tight and … as you wish.
Dont be that obsessive, take that and make use of it. Your feasible
region is contained here.
On Aug 26, 11:53 am, “/\ l_ !” wrote:
thank you but there is still a problem here
in case both Y(i,j) and Y(j,i) are 0, in the first two constraints
that you have written g(i,j) and g(j,i) can both be either 1 or 0. for
example considering g(i,j)=1 the first constraint will be 0> > > is correct and thus we’ll have x(i,j)=1 which is wrong and it must be
0 in case Y(i,j)=Y(j,i)=0
On Aug 25, 10:24 pm, “shahin.gela...@gmail.com”
wrote:
Well, perhaps I understood it wrong but I guess Y is integer non
necessarily binary.
Okay, I was extremely busy and brain was not working when I wrote the
last post.
There is indeed a linear way to do that but of course nut of numerical
interest.
introduce g(i,j)as binary variable, f(i,j) as binary and M a big
constant.
Y(i,j) >> > > > Y(j,i) >> > > > f(i,j) >= g(i,j)
f(i,j) >= g(j,i)
x(i,j) = f(i,j)
I hope I haven’t done any mistake here. otherwise you will find it.
On Aug 25, 5:49 pm, Alexander wrote:
Ali,
If the objective function does not push X in one direction you need
more
than one constraint.
To keep things simpler forget about the indices and have the example
if (Y1=1 or Y2=1) then X=1 else X=0.
You can write the following (this may not be the unique or best way
for
your problem, but works)
- Y1 in {0,1}, Y2 in {0,1}, X in [0,1]
- X>>> > > > > which ensures that X=0 if both Y1 and Y2 are 0.
if either Y1=1 or Y2=1 the constraint becomes redundant X>>> > > > > if both Y1=1 and Y2=1 the constraint becomes redundant X >
- X>= Y1
which ensures that X=1 if Y1=1
if Y1=0 the constraint becomes redundant X>=0
- X>= Y2
which ensures that X=1 if Y2=1
if Y2=0 the constraint becomes redundant X>=0
In general there are well-established techniques to write this type of
constraints. Have a look at the following links to see how we used
such
techniques in problems involving reaction networkshttp://dx.doi.org/10.1186/1752-0509-5-107http://dx.doi.org/10.1371/jo…
We cite some of the old work dealing with these techniques.
On Aug 25, 11:42 am, “/\ l_ !” wrote:
This is an optimization model. My model has Y(i,j) as an output. Then
I want to define this binary variable X to use it in another
constraint so as to have some certain Y(i,j)s.
On Aug 25, 7:07 pm, “shahin.gela...@gmail.com”
wrote:
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j)>>>>>> > > > > > > > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
How should I write it in GAMS
Thanks a lot.
–
“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
…
read more »
\
well, then I would suggest you to consult with a book on linear
programming.
On Aug 27, 12:00 pm, “/\ l_ !” wrote:
With these constraints X(i,j) would be equal to 1 for all the Y(i,j)s.
So what’s the point of defining a binary variable if it is gonna be 1
all the time. Instead of that I could simply define it as a parameter
X(i,j)=1!
On Aug 26, 2:17 pm, “shahin.gela...@gmail.com”
wrote:
my friend, if it does not make you objective better then leave it to
be any thing as long as it does not cut off part of your feasible
region.
have you ever though why most of MIP are extremely challenging for
solvers? why people designed different customized B&B rules? . Because
the know such behaviors and they just dont want to leave it to a
generic MIP solver to spend time on it blindly.
Only for very few class of problems an ideal formulation is known
which is tight and … as you wish.
Dont be that obsessive, take that and make use of it. Your feasible
region is contained here.
On Aug 26, 11:53 am, “/\ l_ !” wrote:
thank you but there is still a problem here
in case both Y(i,j) and Y(j,i) are 0, in the first two constraints
that you have written g(i,j) and g(j,i) can both be either 1 or 0. for
example considering g(i,j)=1 the first constraint will be 0>> > > > is correct and thus we’ll have x(i,j)=1 which is wrong and it must be
0 in case Y(i,j)=Y(j,i)=0
On Aug 25, 10:24 pm, “shahin.gela...@gmail.com”
wrote:
Well, perhaps I understood it wrong but I guess Y is integer non
necessarily binary.
Okay, I was extremely busy and brain was not working when I wrote the
last post.
There is indeed a linear way to do that but of course nut of numerical
interest.
introduce g(i,j)as binary variable, f(i,j) as binary and M a big
constant.
Y(i,j) >>> > > > > Y(j,i) >>> > > > > f(i,j) >= g(i,j)
f(i,j) >= g(j,i)
x(i,j) = f(i,j)
I hope I haven’t done any mistake here. otherwise you will find it.
On Aug 25, 5:49 pm, Alexander wrote:
Ali,
If the objective function does not push X in one direction you need
more
than one constraint.
To keep things simpler forget about the indices and have the example
if (Y1=1 or Y2=1) then X=1 else X=0.
You can write the following (this may not be the unique or best way
for
your problem, but works)
- Y1 in {0,1}, Y2 in {0,1}, X in [0,1]
- X>>>> > > > > > which ensures that X=0 if both Y1 and Y2 are 0.
if either Y1=1 or Y2=1 the constraint becomes redundant X>>>> > > > > > if both Y1=1 and Y2=1 the constraint becomes redundant X >
- X>= Y1
which ensures that X=1 if Y1=1
if Y1=0 the constraint becomes redundant X>=0
- X>= Y2
which ensures that X=1 if Y2=1
if Y2=0 the constraint becomes redundant X>=0
In general there are well-established techniques to write this type of
constraints. Have a look at the following links to see how we used
such
techniques in problems involving reaction networkshttp://dx.doi.org/10.1186/1752-0509-5-107http://dx.doi.org/10.1371/jo…
We cite some of the old work dealing with these techniques.
On Aug 25, 11:42 am, “/\ l_ !” wrote:
This is an optimization model. My model has Y(i,j) as an output. Then
I want to define this binary variable X to use it in another
constraint so as to have some certain Y(i,j)s.
On Aug 25, 7:07 pm, “shahin.gela...@gmail.com”
wrote:
Well this is the objective function which guides your X to take 1 “if
necessary!”.
You don’t have to worry about it.
I dont know any linear form that fulfills your wish.
Are you doing feasibility problem or optimization with an objective?
On Aug 25, 4:55 pm, “/\ l_ !” wrote:
Lets Suppose Y(i,j)=1 and Y(j,i)=1 then according to the constraint
you’ve written we’ll have X(i,j)>>>>>>> > > > > > > > > it can be X(i,j)=0 too. Because both answers fit in the constraint
X(i,j) >
On Aug 25, 5:51 pm, “shahin.gela...@gmail.com”
wrote:
well this is a modelling question not much to do with gams:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
converts to
X(i,j) >
this lets your X moves to its upper bound if needed once either of Ys
is >= 1 and make it zero once both are zero.
Does it solve your problem?
On Aug 25, 2:55 pm, “/\ l_ !” wrote:
Thank you, I made a mistake in defining it
it must be this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=Y(j,i)=0
Now how should I write this code in GAMS?
I think it’s a tough work.
On Aug 25, 3:29 pm, “shahin.gela...@gmail.com”
wrote:
Sorry, that was a typo, look at this:
Lets clarify the things here:
if Y(i,j)==1 && Y(j,i)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
On Aug 25, 12:12 pm, “/\ l_ !” wrote:
How Can Y(i,j) be 1 and 0 at the same time??!!!
Y(i,j) is either 1 or 2 or 3 or 0 or any other integer.
On Aug 25, 1:56 pm, “shahin.gela...@gmail.com”
wrote:
Ali,
Lets clarify the things here:
if Y(i,j)==1 && Y(i,j)==0 then we have:
- (Y(i,j)>= 1 or Y(j,i) >=1) is true and therefore X(i,j) must
be 1,
at the same time:
- (Y(i,j) ==0 or Y(j,i)==0 ) is true and therefore X(i,j) must
be 0
Am I doing something wrong here?
On Aug 25, 4:40 am, “/\ l_ !” wrote:
Dear Shahin I don’t understand what you mean.
X(i,j) is a binary variable and Y(i,j) is an integer variable. For any
Y(i,j) or Y(j,i) which is greater or equal to 1, our binary variable
X(i,j) must be 1 and for Y(i,j) or Y(j,i) equal to 0 the binary
variable should be equal to 0 too.
You say what happens if Y(i,j)=1, then according to the first
statement X(i,j)=1
On Aug 25, 12:31 am, “shahin.gela...@gmail.com”
wrote:
Ali, the conditions are a bit strange and contradicting:
what happens if Y(i,j)==1 && Y(i,j)==0
then according to the first constraint you have X(i,j)=1
and according to the next one you have X(i,j)=0
are you sure the set is correct?
Otherwise, depending on what kind of solver you used there, in
general, such constratinst can be epressed differently.
E.g. in cplex you can make use of indicators.
Shahin Gelareh
On Aug 24, 1:31 pm, “/\ l_ !” wrote:
Yeah, I know I should write the conditions but what should I write?!!
I mean can anybody write the codes here. I write it again:
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if Y(i,j)>=1 or Y(j,i)>=1
X(i,j)=0 if Y(i,j)=0 or Y(j,i)=0
On Aug 24, 1:37 pm, Krishna Prasad wrote:
Hi,
I think you need to declare it as binary variable first, then use
what ever is you conditions, i.e in GAMS
*
Binary Variable X(i,j) some descriptions;*
then write the conditions…
On Wed, Aug 24, 2011 at 12:36 PM, /\ l_ ! wrote:
Hello Everybody
This might seem very simple but I’m new to GAMS.
I want to write a binary variable in my model.
Suppose X(i,j) is the binary variable, I want to define it this way:
X(i,j)=1 if
…
read more »
\