(1) If your write
param demandNc {Sectorofvessel} >= 0;
and then later in the model you write
param demandNc {i in Vessel} = sum {m in Sectorofvessel:originofsectorvessel[m]=i} demandNc[m];
then you have defined demandNc twice, and AMPL will give a "demandNc is already defined" error for the second definition. Probably you want demandNc to be defined by the expression to the right of the = sign; in that case, you should use only the second definition in your model, and not the first one. (If you want to make a one-time assignment of the expression to demandNc, then use the first definition in your model, and then *after* reading the model and the data, execute
let {i in Vessel} demandNc[i] := sum {m in Sectorofvessel:originofsectorvessel[m]=i} demandNc[m];
This is probably not want you want to do, however, unless you have a complex AMPL command script.)
(2) Your model defines
var Occupiedservicetimestep
{i in Vessel,t in Timestep: t <= timeamount-servicehour[i]+1 and t >= arrivaltime[i]} binary;
AMPL's display command can be used to view the indexing set for this variable:
ampl: display {i in Vessel,t in Timestep: t <= timeamount-servicehour[i]+1 and t >= arrivaltime[i]};
set {i in Vessel, t in Timestep: t <= timeamount - servicehour[i] + 1 && t >=
arrivaltime[i]} :=
(0,0) (0,3) (0,6) (1,4) (2,1) (2,4) (3,2) (3,5)
(0,1) (0,4) (1,2) (1,5) (2,2) (2,5) (3,3) (3,6)
(0,2) (0,5) (1,3) (1,6) (2,3) (2,6) (3,4);
You can see that (0,7) is not in this set, and that is why the reference to Occupiedservicetimestep[0,7] in your constraint timecontinuity[0,5,7] is rejected with an "invalid subscript" error.
Bob Fourer
--
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.
param demandNcm {Sectorofvessel} >= 0;
param demandNc {i in Vessel} = sum {m in Sectorofvessel:originofsectorvessel[m]=i} demandNcm[m];
Thus i have defination to both demandNc[i] and demandNcm[m].
2 For var Occupiedservicetimestep, yes I got the matrix.
So in this case, we have binary value for variables inside the matrix. For those not inside, take (0,7) for example, it should be just 0.
My question is: how to tell ampl that just figure our values inside the matrix to be 0 or 1, considering those outside values to be 0?