I am writing a bilevel model on GAMS and i am using the EMP tool to solve it. I need the dual variables of a certain equation to be assigned to a variable called lamda which i am using in the upper level problem. Till this stage that's perfectly fine as i use the following command dualvar Lamda P_Balance which assigns the dualvariables of the equations P_Balance to Lamda. Both of the variable Lamda and the P_balance equations are defined over set i /1*33/ (Variable Lamda(i) and P_balance(i)). However, i need only Lamda(3), Lamda(22), and Lamda(25) in the upper level objective function. So, i wrote the upper level objective function as follows
Prof =e= sum((DG_Inv1, b), (MC(DG_Inv1, b) * Pg(DG_Inv1, b))) - sum((Inv1_N, DG_Inv1, b), Lamda(Inv1_N) * Pg(DG_Inv1, b));
such that Inv1_N is a set includes /3, 22, 25/. I have tried writing that equation in different ways, but Unfortunately i always receive the following error:
*** JAMS Pre processing failed
***
**** ERRORS/WARNINGS IN EQUATION P_Balance(1)
AND VARIABLE Lamda(3)
1 error(s): dualVAR pair has different domains
1 error(s): dualVar pair of different size
**** ERRORS/WARNINGS IN EQUATION P_Balance(2)
AND VARIABLE Lamda(22)
1 error(s): dualVAR pair has different domains
**** ERRORS/WARNINGS IN EQUATION P_Balance(3)
AND VARIABLE Lamda(25)
1 error(s): dualVAR pair has different domains
If you don't mind, would you please help me in rewriting the Obj function in a way that can only select Lamdas of i = 3, 22, 25 and at the same time the command Dualvar Lamda P_balance is not violated? or how can i assign from the beginning the dual variables of P_balance at i = 3, 22, 25 to Lamda while keeping the objective function as written?
Here is that part of my code:
Variable Prof;
Variable Lamda(i);
.
.
.
.
ULPObj..
* Prof =e= sum( (DG_Inv1,b) , (MC(DG_Inv1,b)*Pg(DG_Inv1,b)) ) - sum( (i$(ord(i) and i=ord(Inv_N)), DG_Inv1, b ) , Lamda(i)*Pg(DG_Inv1,b) );
* Prof =e= sum( (DG_Inv1,b) , (MC(DG_Inv1,b)*Pg(DG_Inv1,b)) ) - sum( (i, DG_Inv1, b )$(i IN (Inv_N)) , Lamda(i)*Pg(DG_Inv1,b) );
* Prof =e= sum( (DG_Inv1,b) , (MC(DG_Inv1,b)*Pg(DG_Inv1,b)) ) - sum( (Inv1_N,DG_Inv1, b) , Lamda(Inv1_N)*Pg(DG_Inv1,b) );
* Prof =e= sum((DG_Inv1, b), (MC(DG_Inv1, b) * Pg(DG_Inv1, b)))
* - sum((i, DG_Inv1, b)$(i IN Inv1_N), Lamda(i) * Pg(DG_Inv1, b));
Prof =e= sum((DG_Inv1, b), (MC(DG_Inv1, b) * Pg(DG_Inv1, b)))
- sum((Inv1_N, DG_Inv1, b), Lamda(Inv1_N) * Pg(DG_Inv1, b));
.
.
.
.
P_Balance(i)..
sum((D,k)$DB(i,D),Pd(D,k)) + sum(j$cx(j,i), Pij(i,j)) - sum((DG,b)$DGB(i,DG),Pg(DG,b)) =e= 0;
.
.
.
.
.
$onecho > "%emp.info%"
bilevel X
min Z * Equations
dualvar Lamda P_Balance
$offecho
I kindly expect a help in writing the upper level objective function or modifying the dualvar command in a way that to assign only the required dual variables