[AMPL 18393] What's wrong in this code?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 18393] What's wrong in this code?

electrolion0
set Factory;
set Depot;
set Customer;

param FD >= 0;
param FC >= 0;
param DC >= 0;
param DepotConst >= 0;
param CustConst >= 0;
param FactConst >= 0;

var X{Factory, Depot} >= 0;
var Y{Depot, Customer} >= 0;
var Z{Factory, Customer} >= 0;

minimize COST: sum{i in Factory, j in Depot}(FD * X[i,j]) + sum{j in Depot, k in Customer}(DC * Y[j,k]) + sum{i in Factory, k in Customer}(FC * Z[i,k]);

subject to
C1{i in Factory}: sum{i in Factory, j in Depot}X[i,j] + sum{i in Factory, k in Customer}Z[i,k] <= FactConst[i];
C2{j in Depot}: sum{j in Depot, k in Customer}Y[j,k] <= DepotConst[j];
C3{k in Customer}: sum{i in Factory, k in Customer}Z[i,k] + sum{j in Depot, k in Customer}Y[j,k] >= CustConst[k];

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 18399] What's wrong in this code?

AMPL mailing list
Consider this constraint from your model:

C2 {j in Depot}: sum {j in Depot, k in Customer} Y[j,k] <= DepotConst[j];

You define the constraint to be indexed over j in Depot. Thus it is an error to also try to sum over j in Depot inside the constraint expression. You could use a different index for the summation, for example sum {j2 in Depot, k in Customer} Y[j2,k], but I think it is more likely that you don't want to sum over j at all:

C2 {j in Depot}: sum {k in Customer} Y[j,k] <= DepotConst[j];

Similar comments apply to your other two constraints.

--
Robert Fourer
[hidden email]
{#HS:803954611-38678#}
On Sun, Mar 17, 2019 at 1:04 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
set Factory;
set Depot;
set Customer;

param FD >= 0;
param FC >= 0;
param DC >= 0;
param DepotConst >= 0;
param CustConst >= 0;
param FactConst >= 0;

var X{Factory, Depot} >= 0;
var Y{Depot, Customer} >= 0;
var Z{Factory, Customer} >= 0;

minimize COST: sum{i in Factory, j in Depot}(FD * X[i,j]) + sum{j in Depot, k in Customer}(DC * Y[j,k]) + sum{i in Factory, k in Customer}(FC * Z[i,k]);

subject to
C1{i in Factory}: sum{i in Factory, j in Depot}X[i,j] + sum{i in Factory, k in Customer}Z[i,k] <= FactConst[i];
C2{j in Depot}: sum{j in Depot, k in Customer}Y[j,k] <= DepotConst[j];
C3{k in Customer}: sum{i in Factory, k in Customer}Z[i,k] + sum{j in Depot, k in Customer}Y[j,k] >= CustConst[k];



--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.