# [AMPL 2113] matrices Classic List Threaded 2 messages Open this post in threaded view
|

## [AMPL 2113] matrices

 Matrices problem can be solved by using these two commands: ‘for all’ and ‘sum’ in Mosel language like: For all(j in NG) sum(l in NL) A(j,l)*pf(l)=(PG(j)+dpgplus(j)-dpgminus(j)-P_DEMAND(j)) There are lots of errors when I use only sum (l in NL) A(i.l)*pf(l) about unknown 'i' in AMPL.  Which chapter of AMPL book does focus on matrices? In which chapter can I find an example of matrices

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---

Open this post in threaded view
|

## [AMPL 2114] Re: matrices

A matrix in AMPL is an entity indexed over two sets, or more generally over a set of ordered pairs.  Chapter 6 of the AMPL book discusses indexing of this sort.  For the example you give, you could write in AMPL:

subj to DemandConstraint {j in NG}:

sum {l in NL} A[j,l] * pf[l]

= PG[j] + dpgplus[j] - dpgminus[j] - P_DEMAND[j];

Of course before specifying this constraint you would have to define the entities that appear in it.  To define the "matrix" A you could specify:

param A {NG,NL};

Bob Fourer

From: [hidden email] [mailto:[hidden email]]

On Behalf Of mahbube zeraatzade
Sent: Friday, December 05, 2008 3:52 PM
To: [hidden email]
Subject: [AMPL 2113] matrices

 Matrices problem can be solved by using these two commands: ‘for all’ and ‘sum’ in Mosel language like: For all(j in NG) sum(l in NL) A(j,l)*pf(l)=(PG(j)+dpgplus(j)-dpgminus(j)-P_DEMAND(j)) There are lots of errors when I use only sum (l in NL) A(i.l)*pf(l) about unknown 'i' in AMPL.   Which chapter of AMPL book does focus on matrices? In which chapter can I find an example of matrices

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---