urgent help about set

Hello all
I am working on a model in which I have a set of elements
Set v /v1*v10/ ;
And for each member of this set I want to introduce a new set which contains all the rest members of mother set v except that element
For example for v1 the new set will be from v2 to v10, for v2 the new set will be v1, v3 …v10

Please help me in this matter that how it is possible to write such a set

Your help is so appreciated.
Regards

\

please refer to the attached file for more information, thanks all


question.docx (13.5 KB)

I have written the code like this but I am sure that it is not true, because the answer is so far from what we expect:

set j /j1j10/ ;
alias(j,j’) ;
set v /v1
v20/ ;
alias(v,v’) ;
obj … z=e=sum(j,(sum(j’,sum((v,v’),L(v,v’)*x(v,j)*x(v’j’)))) ;


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/d/optout.

Hi Mahmood,

the easiest way for you can be defining a parameter like b(v,v) = 0, alias(v,vp), then
for (v,
for(vp,
if not(sameas(v,vp), (b(v,vp) = 1);
);
);
then you can use $ operator in your equations.
OR
you can directly define your sets. v1(v) = {…}, v2(v) = {…}
I am sure there would be more techniques, but these two are among easiest ones.

best,

On Sun, Feb 1, 2015 at 6:04 AM, mahmood golabi wrote:

Hello all
I am working on a model in which I have a set of elements
Set v /v1*v10/ ;
And for each member of this set I want to introduce a new set which contains all the rest members of mother set v except that element
For example for v1 the new set will be from v2 to v10, for v2 the new set will be v1, v3 …v10

Please help me in this matter that how it is possible to write such a set

Your help is so appreciated.
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/d/optout.



\

Babak Saleck Pay
Ph.D Student of Systems Modeling and Analysis
Department of Statistical Sciences and Operations Research
Virginia Commonwealth University
4156 Grace Harris Hall
1015 Floyd Ave.
Richmond, VA

\

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/d/optout.

Thanks Babak,
but there is another problem in gams, it says that for index should be scalar, and it has caused too many errors, I have typed like this:
set v /v1*v10/ ;
alias (v,u);
parameter q(v,u)=0 ;
for (v,
for (u,
if not (sameas(v,u),(q(v,u)=1));
);
);
and also after solving this problem how it is possible to use dollar symbol in the calculation as you said? I am so amateur in gams, sorry for this funny questions

\

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/d/optout.

Sorry, use “loop”. It was my mistake.

cheers,


On Mon, Feb 2, 2015 at 8:13 AM, mahmood golabi wrote:

Thanks Babak,
but there is another problem in gams, it says that for index should be scalar, and it has caused too many errors, I have typed like this:
set v /v1*v10/ ;
alias (v,u);
parameter q(v,u)=0 ;
for (v,
for (u,
if not (sameas(v,u),(q(v,u)=1));
);
);
and also after solving this problem how it is possible to use dollar symbol in the calculation as you said? I am so amateur in gams, sorry for this funny questions

\

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/d/optout.



\

Babak Saleck Pay
Ph.D Student of Systems Modeling and Analysis
Department of Statistical Sciences and Operations Research
Virginia Commonwealth University
4156 Grace Harris Hall
1015 Floyd Ave.
Richmond, VA

\

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/d/optout.

Hello,
You can do as:
Set V /V1 * V10/
I(V,V);
Alias(V,V2);
I(V,V2)=Yes;
I(V,V)=No;
Display I;

the result is:
---- 6 SET I

V1 V2 V3 V4 V5 V6

V1 YES YES YES YES YES
V2 YES YES YES YES YES
V3 YES YES YES YES YES
V4 YES YES YES YES YES
V5 YES YES YES YES YES
V6 YES YES YES YES YES
V7 YES YES YES YES YES YES
V8 YES YES YES YES YES YES
V9 YES YES YES YES YES YES
V10 YES YES YES YES YES YES

  •      V7             V8           V9          V10
    

V1 YES YES YES YES
V2 YES YES YES YES
V3 YES YES YES YES
V4 YES YES YES YES
V5 YES YES YES YES
V6 YES YES YES YES
V7 YES YES YES
V8 YES YES YES
V9 YES YES YES
V10 YES YES YES


On Mon, Feb 2, 2015 at 6:59 PM, Bob Pay wrote:

Sorry, use “loop”. It was my mistake.

cheers,


On Mon, Feb 2, 2015 at 8:13 AM, mahmood golabi wrote:

Thanks Babak,
but there is another problem in gams, it says that for index should be scalar, and it has caused too many errors, I have typed like this:
set v /v1*v10/ ;
alias (v,u);
parameter q(v,u)=0 ;
for (v,
for (u,
if not (sameas(v,u),(q(v,u)=1));
);
);
and also after solving this problem how it is possible to use dollar symbol in the calculation as you said? I am so amateur in gams, sorry for this funny questions

\

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/d/optout.



\

Babak Saleck Pay
Ph.D Student of Systems Modeling and Analysis
Department of Statistical Sciences and Operations Research
Virginia Commonwealth University
4156 Grace Harris Hall
1015 Floyd Ave.
Richmond, VA

\

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/d/optout.

\

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/d/optout.