how to write the row of sets

Problems with syntax of GAMS
zhiping fan
User
User
Posts: 9
Joined: 3 years ago

how to write the row of sets

Post by zhiping fan »

Hi, everyone.
I want to express the row of a set in my code.for example, I get a multi-dimension set and I hope to write the row of the set.
1.png
I want to write the red part.
thank you so much
Last edited by zhiping fan 3 years ago, edited 2 times in total.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: remove the duplicate item

Post by Renger »

Hi
Use the same logic for i and k for b(j,i,k):

Code: Select all

b(j,i,k)$(ord(i) ne ord(k) .....)
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
zhiping fan
User
User
Posts: 9
Joined: 3 years ago

Re: remove the duplicate item

Post by zhiping fan »

Hi,
Thank you so much for your help.
Maybe a misunderstand existing in my text, I try it as your advice, the correct answer is b(j,i,k)$(ord(i) = ord(k))=no;it can realize my target.
Due to I am a beginner and no experience in GAMS, I have other questions in my study.
How can realize the following aim.
The attachment 3.png is no longer available
5.png
As a previous statement. I have declared the node and its parentnode and now I do not know how to control the sign 'B' in a general form or how to declare it.
5.png
Thanks again.
regards
zhiping fan
User
User
Posts: 9
Joined: 3 years ago

Re: remove the duplicate item

Post by zhiping fan »

Hi, everyone.
The last email maybe has an error and I want to realize the following aim. But no idea in my mind.
1.png
2.png
,
how can I control the sign B.
thanks again.
zhiping fan
User
User
Posts: 9
Joined: 3 years ago

Re: remove the duplicate item

Post by zhiping fan »

Hi,
Now I have a question about the row of sets.
I get a set-a like fig11, now I need to use the result of set a and set b, but how can I express the row of a and b?
I try it like fig14 but it is wrong, could you help me?
thanks.
11.png
12.png
12.png (5.88 KiB) Viewed 4424 times
13.png
13.png (6.33 KiB) Viewed 4424 times
14.png
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: remove the duplicate item

Post by Renger »

Hi
From your question, it is not clear for me what you are trying to do. Please submit the code that produces the error and write what you want to achieve with your equation that produces an error.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
zhiping fan
User
User
Posts: 9
Joined: 3 years ago

Re: remove the duplicate item

Post by zhiping fan »

Hi Renger,
Thank you for your reply.
in my case, I want to express the relationship between the node and its parent nodes.
In previous work, I have got the matrix like fig 1.now I need to write the constraint between the node and its parent nodes, for example, in fig 1, I want to give the constraint of j and the element of j is {a,b,c,d,e}, and its parent node is B ,
0.png
its element is {a.b a.c a.d a.e b.c b.d b.e c.d c.e....}, I want to write the general constraint.
now I put B as a set, so when I express B, the error is listed as the attachments.
0.png
1.png
2.png
3.png
regards
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: remove the duplicate item

Post by Renger »

Hi

Your equation should read

Code: Select all

cons10(j,n).. 
	a0(j,n) =G= 0;
Note, that you always should correct the first error that appears in your code and don't pay too much attention to the errors that follow as they are often caused by the first error. In your case, equation eqt is missing the "..".
Furthermore, it is easer for the person who wants to help you to provide the code that causes the error (instead of including screenshots). You can either attach a file or put the code in a code block (the </> symbol in the editor.

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
zhiping fan
User
User
Posts: 9
Joined: 3 years ago

Re: remove the duplicate item

Post by zhiping fan »

Hi Renger,
Thank you for your reply.
I try to modify the code as your advice, but the errors still exist.
1.png
1.png (6.69 KiB) Viewed 4355 times
2.png
2.png (7.93 KiB) Viewed 4355 times
3.png
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: remove the duplicate item

Post by Renger »

You have the same kind of problem in equation eqt: you use a lot of indices on the RHS, but z has no indices, nor has the equation itself. You should have the same number of dimensions/indices on both sides and in the equation name.

Examples

Code: Select all

Eq1(j)  z(j) =e= a(j)*f;

Code: Select all

Eq2.. p =e= sum(j, b(j));

Code: Select all

Eq3.. t =e= h("1");
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply