I keep getting the error on the last 2 lines, but not the cost line and i dont really get why, any help would be much appreciated.
`Sets
i POSITIONS / P1, P2, P3, B, DG, V1, V2, V3, H, F /
;
alias(i,j)
;
....
Variables
X(i,j) wether node i and node j are connected [binary variable]
C total cost of the connections
Binary variable X
;
Equations
cost, connected, self;
cost.. C =e= SUM[(i,j), X(i,j)*sqrt(sqr(CX(i)-CX(j))+sqr(CY(i)-CY(j)))*VC+FC]
;
connected.. SUM[(j), X(i,j)] + SUM[(j), X(j,i)] =g= 1;
self.. X(i,i) =e= 0;
....`
Ive been whatver i can find online but from the examples i can find i cant really find the issue
urgent help with error 149
Re: urgent help with error 149
Hi,
You are not controlling the `i` index in the equations properly. For equation connected, which element(s) of `i` should be used. It is not clear from how you define the equation. Maybe this equation should be generated for all elements in `i`? Then you need to use `i` in the equation domain.
Same applies for equation self, but there you could also just get rid of the equation and fix the corresponding variables to zero.
In general, when sharing code, I suggest sharing the full code such that other forum users can reproduce what your are doing.
Best,
Fred
You are not controlling the `i` index in the equations properly. For equation connected, which element(s) of `i` should be used. It is not clear from how you define the equation. Maybe this equation should be generated for all elements in `i`? Then you need to use `i` in the equation domain.
Code: Select all
connected(i).. SUM[(j), X(i,j)] + SUM[(j), X(j,i)] =g= 1;
Code: Select all
X.fx(i,i) = 0;
Best,
Fred