--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
You can use compound sets. You can read about it at https://ampl.com/BOOK/CHAPTERS/09-sets2.pdf (pp 96).
--
Paras Tiwari
am...@googlegroups.com
On Fri, May 18, 2018 at 12:57 AM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+unsubscribe@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+unsubscribe@googlegroups.com.
param I integer > 0; param J {i in 1..I} integer > 0; param L integer > 0; param T integer > 0; param demand {1..I, 1..T}; param flow {1..L, 1..T}; param shift {1..I, 1..L}; var pk {i in 1..I, 1..J[i], 1..T} >= 0; subject to SystemDemand {t in 1..T}: sum {i in 1..I} (sum {j in 1..J[i]} pk[i,j,t] - demand[i,t]) = 0; subject to PowerFlow {l in 1..L, t in 1..T}: flow[l,t] = sum {i in 1..I} shift[i,l] * (sum {j in 1..J[i]} pk[i,j,t] - demand[i,t]);
set HOURS = 1..T;
as in my previous example.Dear Dr. Fourer,
It was great to hear from you. I have started following your book.
In my previous code, for simplicity, I did not include two more constraints that I have to deal with. With the level of knowledge I have right now, it seems there must be some trick to deal with the constraints.
minimize sum (t in hour)(sum (i in units)(p[t])*i.cost);
subject to{
//capacity
forall(i in units,t in hour){
i.Pmax*x[t]>=p[t];
i.Pmin*x[t]<=p[t];
};
//Demand
forall (t in hour){
sum (nodenumG in nodeG)(sum (i in units: i.buslocation==nodenumG)(p[t])-localdemandG[nodenumG][t])+
sum (nodenumNG in nodeNG)(-localdemandNG[nodenumNG][t])==0;
};
//Powerflow
forall( l in branches, t in hour){
flow[l][t]== sum (nodenumG in nodeG)(alphaG[l][nodenumG]*(sum (i in units: i.buslocation==nodenumG)(p[t])-localdemandG[nodenumG][t]))+
sum (nodenumNG in nodeNG)(alphaNG[l][nodenumNG]*(-localdemandNG[nodenumNG][t]));
}
}//end of subject to
I would like to thank Dr. Tiwari as well for his help so far. Thank you again for your time.
Best Regards,
Udoy Paul
On Fri, May 18, 2018 at 5:41 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
AMPL does not have any construct like the OPL's tuples. However there is often a simple way to say the same thing in AMPL. As an example, for the OPL objective and constraints that you show, an AMPL definition could be as follows:
param T > 0;
set HOURS := 1 .. T;
set UNITS;
param cost {UNITS};
param Pmin {UNITS};
param Pmax {UNITS};
var p {UNITS, HOURS} >= 0, <= 3000;
var x {UNITS, HOURS} binary;
minimize TotalCost: sum {i in UNITS, t in HOURS} cost[i] * p[i,t];
subject to CapacityMin {i in UNITS, t in HOURS}:
Pmin[i] * x[i,t] <= p[i,t];
subject to CapacityMax {i in UNITS, t in HOURS}:
Pmax[i] * x[i,t] >= p[i,t];
Other uses of tuples in OPL may require sets of ordered pairs, triples, etc. in AMPL; for example a set of network arcs would be defined as a set of pairs of nodes. These are what AMPL calls "sets of tuples" and they are described in the reference given by Paras.
--
Robert Fourer
am...@googlegroups.com
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.