Hello all,

I am doing optimization for devices’ capacity in order to minimum the cost under the circumstance that every node’s voltage is maintained in an acceptable level. The mathematical expression of the model ,the code and the log are attached.

Error 141 and 143 are alarmed repeatedly.

So,please tell me what should I do.

Thanks in advance for your help.

log.txt (10 KB)

code.gms (2.06 KB)

You can’t write constraints like this in GAMS:

```
if((ud11=0)and(ud12=0)and(ud13=0),
ud1.fx=1;
else
ud1.fx=0;);
```

GAMS requires your to rewrite your constraint without *if*, *and* and *else*. While there are systems that automatically rewrite this for you they often do a poor job. Often you can reuse subexpressions and so forth to get a tighter formulation. I suggest you read up on modeling with logical constraints e.g. in the book *Model Building in Mathematical Programming* by HP Williams (https://books.google.de/books?id=Cd1HiA--dBcC). I believe OPL from IBM does this automatic reformulation if you don’t want to bother learning the reformulation methods.

-Michael

Thank you for your prompt reply. In the book Nonlinear Optimization Applications Using the GAMS Technology by Neculai Andrei, the IF statement can be used to control the execution of statements.Since I want to describe a piecewise function, how should I revise my code?

Again, HP Williams is a good source for piecewise linear approximations and how to model them. There are a couple of example in the GAMS Model Library, e.g. https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_trnspwl.html.

-Michael