How to count the number of variables?

Hello, does anyone can help me with counting the number of the solutions?
Suppose I have a set of x(k,n) as following:

x(1,1) = …,
x(1,2) = …,
.
x(1,n) =…,
.
x(k,n) = …,

how can i count the number of variables by dimension “k” or “n”? e.g. how many x(1,n) in the optimal solution? Thanks in advance!


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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Peiyu



I probably don’t understand your question, because the number of x(1,?) is in this case n (or in Gams card(n)).

I assume you have n x for k=1 and only some of them contain a solution, and now you want to know how many there are. Let us assume that if x(k,n) is equal to 2, this means you have a solution, and otherwise there is no solution.



You could do this as follows:



Parameter numbersolutions(k) Number of solutions for each k;



Numbersolutions(k) = sum(n$(x(k,n) = 2), 1);



This sums the value of 1 only then when x(k,n) equal is to 1.



Hope this helps

Cheers

Renger





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Peiyu Luo
Sent: Wednesday, March 23, 2016 2:09 AM
To: gamsworld
Subject: How to count the number of variables?



Hello, does anyone can help me with counting the number of the solutions?

Suppose I have a set of x(k,n) as following:



x(1,1) = …,

x(1,2) = …,

.

x(1,n) =…,

.

x(k,n) = …,



how can i count the number of variables by dimension “k” or “n”? e.g. how many x(1,n) in the optimal solution? Thanks in advance!


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 https://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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.