Forum Discussion

FICO's avatar
FICO
Community Manager
3 years ago

Error 101: Incompatible types for operators

I'm trying to optimize a Power System economic dispatch.

My code is the following:

model ProblemaMultimodal

uses "mmxprs"; 

!Declaraciones de varaibles y parámetros

declarations

Pg1:mpvar 

Pg2: mpvar

Pg3: mpvar

ENS: mpvar

Xg1: mpvar

Xg2: mpvar

Xg3: mpvar

f12: linctr

f13: linctr

f23: linctr

theta1: linctr

theta2: linctr

theta3: linctr

L=70 !(MW)

Pg1Max=50

Pg1Min=0

Pg2Max=20

Pg2Min=4

Pg3Max=30

Pg3Min=10

f12Max=50

f13Max=50

f23Max=50

X12=0.1

X13=0.1

X23=0.1

balance1: linctr

balance2: linctr

balance3: linctr

objective: linctr

ENS_Sol: real

Pg1Sol: real

Xg1Sol: real

Pg2Sol: real

Pg3Sol: real

Xg2Sol: real

Xg3Sol: real

f12Sol: real

f13Sol: real

f23Sol: real

end-declarations

objective:=10*Pg1+100*Pg2+150*Pg3+300*ENS

Xg1 is_binary

Xg2 is_binary

Xg3 is_binary

!balance eléctrico

balance1:=Pg1-f12-f13=0

balance2:= Pg2+f12-f23=0

balance:= Pg3+f12+f23=L-ENS

Pg1<=Pg1Max*Xg1

Pg1>=Pg1Min*Xg1

Pg2<=Pg2Max*Xg2

Pg2>=Pg2Min*Xg2

Pg3<=Pg3Max*Xg3

Pg3>=Pg3Min*Xg3

ENS<=L

-f12Max<=f12<=f12Max

-f13Max<=f13<=f13Max

-f23Max<=f23<=f23Max

f12=(theta2-theta1)/X12

f13=(theta3-theta1)/X13

f23=(theta3-theta2)/X23

theta2=0

-M_PI/2<=theta1<=M_PI/2

-M_PI/2<=theta3<=M_PI/2

!Optimizar

minimise(XPRS_BAR, objective )

writeln("objetive value is ", getobjval, " USD")

!Manipulación

Xg1Sol:=getsol(Xg1)

Pg1Sol:=getsol (Pg1)

ENS_Sol:=getsol (ENS)

Pg2Sol:=getsol (Pg2)

Xg2Sol:=getsol(Xg2)

Pg3Sol:= getsol (Pg3)

Xg3Sol:=getsol(Xg3)

f12Sol:= getsol(f12)

f13Sol:= getsol(f13)

f23Sol:= getsol(f23)

writeln ("Potencia generada por el generador 1: ", Pg1Sol, "Mw")

writeln ("Generador 1 on: ", Xg1Sol,"")

writeln ("ENS: ", ENS_Sol, " Mw")

writeln ("Pg2 potencia generada: ", Pg2Sol, " Mw")

writeln ("Generador 2 on: ", Xg2Sol,"")

writeln ("Pg3 ptencia generada: ", Pg3Sol, " Mw")

writeln ("Generador 3 on: ", Xg1Sol,"")

writeln ("Flujo en la línea12: ", f12Sol,"")

writeln ("Flujo en la línea 13: ", f13Sol, " Mw")

writeln ("Flujo en la línea 23 ", f23Sol,"")

end-model

And I'm getting these errors:

====versions====

Xpress IVE Version 1.25.06 64 bit

Built on Jul 19 2022, 12:42:47

Character encoding: CP1252

Xpress Mosel Version 6.0.1

Xpress Optimizer Version 40.01.03

====messages====

(Line: 96, Col: 20) : error 101: Incompatible types for operator (`linctr' <= `integer' not defined). 

(Line: 97, Col: 20) : error 101: Incompatible types for operator (`linctr' <= `integer' not defined). 

(Line: 98, Col: 20) : error 101: Incompatible types for operator (`linctr' <= `integer' not defined). 

(Line: 106, Col: 23) : error 101: Incompatible types for operator (`linctr' <= `real' not defined). 

(Line: 107, Col: 23) : error 101: Incompatible types for operator (`linctr' <= `real' not defined). 

======end=======

What should I do?

1 Reply

  • FICO's avatar
    FICO
    Community Manager

    With Mosel it is not possible to use several relational operators in a statement defining linear constraints. Instead, I would recommend to use the procedure setrange, for example:

    setrange(f12, -f12Max, f12Max)