Display Question

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Display Question

Post by Archiver »



After the model has run, it is possible to sum a set of variables and
display the sum?

Specifically, I have a variable with two indexes: p(k,i). At the end
of the code I have
display p.l;

which results in the following table

---- 57 VARIABLE p.L dual variable of node i with source k

1 2 3 4 5

1 4.000 4.000 3.000 4.000
2 4.000 1.000 2.000 2.000
3 4.000 1.000 1.000 1.000
4 3.000 2.000 1.000 1.000
5 4.000 2.000 1.000 1.000

What I really want to do is sum across the rows: i.e. the sum of p
(1,i)=4+4+3,4=15, p(2,i)=4+1+2+2=9, ...

Thanks in advance if anyone can help me with this.
Kevin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Display Question

Post by Archiver »

Kevin,

You can do this most easily using a parameter, like this:

parameter rowSum(k);
rowSum(k) = sum{i, p.l(k,i)};
display rowSum;

-Steve

On Tue, Feb 17, 2009 at 10:35 AM, Kevin Kennedy wrote:
> >
> > After the model has run, it is possible to sum a set of variables and
> > display the sum?
> >
> > Specifically, I have a variable with two indexes: p(k,i). At the end
> > of the code I have
> > display p.l;
> >
> > which results in the following table
> >
> > ---- 57 VARIABLE p.L dual variable of node i with source k
> >
> > 1 2 3 4 5
> >
> > 1 4.000 4.000 3.000 4.000
> > 2 4.000 1.000 2.000 2.000
> > 3 4.000 1.000 1.000 1.000
> > 4 3.000 2.000 1.000 1.000
> > 5 4.000 2.000 1.000 1.000
> >
> > What I really want to do is sum across the rows: i.e. the sum of p
> > (1,i)=4+4+3,4=15, p(2,i)=4+1+2+2=9, ...
> >
> > Thanks in advance if anyone can help me with this.
> > Kevin
> > --~--~---------~--~----~------------~-------~--~----~
> > 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
> > -~----------~----~----~----~------~----~------~--~---
> >
> >



-- Steven Dirkse, Ph.D. GAMS Development Corp., Washington DC Voice: (202)342-0180 Fax: (202)342-0181 sdirkse@gams.com http://www.gams.com

Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Display Question

Post by Archiver »



Works great! Thanks for the help and quick reply.

Kevin

On Feb 17, 10:42 am, Steven Dirkse wrote:
> > Kevin,
> >
> > You can do this most easily using a parameter, like this:
> >
> > parameter rowSum(k);
> > rowSum(k) = sum{i, p.l(k,i)};
> > display rowSum;
> >
> > -Steve
> >
> >
> >
> >
> >
> > On Tue, Feb 17, 2009 at 10:35 AM, Kevin Kennedy wrote:
> >
>> > > After the model has run, it is possible to sum a set of variables and
>> > > display the sum?
> >
>> > > Specifically, I have a variable with two indexes: p(k,i). At the end
>> > > of the code I have
>> > > display p.l;
> >
>> > > which results in the following table
> >
>> > > ---- 57 VARIABLE p.L dual variable of node i with source k
> >
>> > > 1 2 3 4 5
> >
>> > > 1 4.000 4.000 3.000 4.000
>> > > 2 4.000 1.000 2.000 2.000
>> > > 3 4.000 1.000 1.000 1.000
>> > > 4 3.000 2.000 1.000 1.000
>> > > 5 4.000 2.000 1.000 1.000
> >
>> > > What I really want to do is sum across the rows: i.e. the sum of p
>> > > (1,i)=4+4+3,4=15, p(2,i)=4+1+2+2=9, ...
> >
>> > > Thanks in advance if anyone can help me with this.
>> > > Kevin
> >
> > --
> > Steven Dirkse, Ph.D.
> > GAMS Development Corp., Washington DC
> > Voice: (202)342-0180 Fax: (202)342-0181
> > sdir...@gams.comhttp://www.gams.com- Hide quoted text -
> >
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Post Reply