variable syntax problem

Hello,

I have 2 issues. Firstly I need to declare the square of a variable with 2 arguments, but sqr(V(i,t)) doesn’t work.
As for the other, I have the following parameter: LPline_max(f,t,seg) and declared the variable LP_line(f,t,seg). However the following equation gives the errors 145 and 148 for both of them.

Net16ap2(f,t) .. LP_line(f,t,1) =l= LPline_max(f,t,1);

.

Thanks in advance.

  1. When you say ‘but sqr(V(i,t)) doesn’t work’ what does this mean. The syntax is correct. But perhaps there is a problem somewhere else.
  2. In GAMS labels always need quoting. So if you want to access the element ‘1’ from seg do it as follows:
Net16ap2(f,t) .. LP_line(f,t,'1') =l= LPline_max(f,t,'1');

-Michael

Thank you for your response,second issue is solved. For the first one, I want to do something like this

Set i /1*24/
               t /1*24/;
Variables
sqr(V(i,t));

but 4 errors appear all the time.

That makes little sense. What should it mean to declare the sqr of a variable? You can use the sqr of a variable in an expression in an equation or in an assignment statement:

Set i /1*24/
    t /1*24/;
Variables V(i,t);
equation e;
e.. sum((i,t), sqr(V(i,t)) =l= 1;

-Michael

I need to solve the problem as mip

MIP often means MILP which only allows linear expressions, so you can’t use sqr of variables. I think you need to go back to the basics. Good luck.

-Michael

I get that, this picture might help you get my point,it wasn’t uploaded at my previous post
Screenshot_1.png

So if the variable only shows up squared in the model then it is a “naming” issue. Just call the variable Vsqr and after the solve you get the value of V by taking sqrt of Vsqr and decide about the sign.

-Michael