[Cmpl] some CMPL errors
Prof. Dr. Mike Steglich
mike.steglich at stegger.net
Mon May 5 11:30:30 EDT 2014
Hi Anna,
I apologize the very delayed answer. There was obesely a misunderstanding between me and Thomas (my teammate) who shout answer you.
Please see my answers below:
Am 30.04.2014 um 17:24 schrieb Anna Tarantini <anna.tarantini at hotmail.it>:
> Hi, we're trying to formulate a simple model to get the layout of a MAN.
> While compiling the CMPL we get some errors:
>
> error(compiler): file prova.cmpl line 55: syntax error, unexpected SYMBOL_VAR
> error(compiler): file prova.cmpl line 64: syntax error, unexpected ASSIGN_ITER, expecting ':'
> error(compiler): file prova.cmpl line 64: syntax error, unexpected '}', expecting end of file
>
> here's the CMPL file
>
>
>
> %arg -ignoreZeros
>
>
>
> parameters:
>
> f:=30;
> alfa:=40;
> r:=(1,2,3,4,5);
> beta:=20;
> omega:=10;
>
> seed:=srand(100);
> M:=10000;
>
> nrOfCities:=5;
> NODES:=1..nrOfCities;
>
> {i in NODES:
> xp[i]:=rand(100);
> yp[i]:=rand(100);
> }
>
> {i in NODES, j in NODES:
> {i==j:
> dist[i,j]:=M; |
> default:
> dist[i,j]:= sqrt( (xp[i]-xp[j])^2 + (yp[i]-yp[j])^2 );
> dist[j,i]:= dist[i,j]+rand(10)-rand(10);
> }
> }
>
>
> #include "istanza0.cmpl"
>
>
> variables:
>
>
>
> w[NODES, NODES]: integer[0..];
>
> y[NODES, NODES]: integer[0..1];
>
> x[NODES, NODES]: integer[0..];
>
>
>
> objectives:
>
>
>
> cost: (sum{j:=1..nrOfCities : sum{i:=1..(j-1): y[i,j] }} * f) +
>
> (alfa * sum{j:=1..nrOfCities: sum{i:=1..(j-1): d[i,j] * w[i,j] }}) -> min;
The parameter array d[,] is not defined. I would assume that you want to use dist[,]. You can additionally simplify your objective function because the two sums run over the same sets.
This is my proposal:
cost: sum{j in 1..nrOfCities, i in 1..(j-1): y[i,j]* f + alfa * dist[i,j] * w[i,j] } -> min;
>
>
>
>
> constraints:
>
> strands { i in NODES, j in NODES : w[i,j] <= k * y[i,j]; }
k is not defined.
>
> flow { j in NODES-1 : sum{ j in NODES, i in NODES : x[j,i] } - sum{ i in NODES, j in NODES : x[i,j] } = r[j] * beta; }
> hubFlow { j in NODES-1 : sum{ j in NODES : x[j, NODES] } - sum{ j in NODES : x[NODES,j] } = - sum{ j in NODES-1 : r[j] * beta }; }
This is a little bit more difficult to answer:
Do you want really to use the index j in the outer and the inner sums? If not please use another index for the outer sum. Do you mean j in (1..nrOfCities-1) instead j in NODES-1. In my mind does make NODES-1 not really sense.
I do not understand the idea of x[j, NODES]. Do you want to address a single element of the array x[,] or the vector out of the matrix x[,]?
>
> capacity { i in NODES, j in NODES : x[j,i] + x[i,j] <= w[i,j] * omega; }
>
>
>
> Any clue of how to resolve those errors?
> Greetings
>
Thanks,
Mike
> Anna
> _______________________________________________
> Cmpl mailing list
> Cmpl at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cmpl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20140505/b64cd231/attachment.html>
More information about the Cmpl
mailing list