## Need help for Ëquation in the pre-triangular part"issue

Problems with syntax of GAMS
tbfakhrim
User
Posts: 1
Joined: 7 months ago

### Need help for Ëquation in the pre-triangular part"issue

Hi, I'm Fakhri, currently doing a project about battery sizing but having compilation problems.

My code is:

*******************************INITIALITATION***********************************
/;

alias (n,b,bb);

***********************************PARAMETERS***********************************
* BESS Constant

Scalar eff_BESS_chg Efficiency of BESS charging /0.92/;
Scalar eff_BESS_dis Efficiency of BESS discharging /0.92/;

Scalar SoC_BESS_min Minimum State of Charge of BESS /0.2/;
Scalar SoC_BESS_max Maximum State of Charge of BESS /0.9/;

Scalar SoC_BESS_init Initial State of Charge of BESS /0.5/;

Scalar number_BESS Number of BESS /1/;

* Pricing Constant

Scalar lambda_batt_deg Battery degradation cost [Eur per kWh] /0.038/;
Scalar cost_BESS_invest BESS investment cost [Eur per kWh] /300/;

* Simulation Constant

Scalar t0 Prevent GAMS to start counting at t=1 /2/;

***********************************VARIABLES************************************

Variables

* BESS Variables

P_BESS(n,t) Accumulated power from BESS per node [kW]
P_BESS_chg(n,t) Charging power to BESS per node [kW]
P_BESS_dis(n,t) Disharging power from BESS per node [kW]

E_BESS_max(n) Maximum capacity of BESS per node [kWh]

SoC_BESS(n,t) State of Charge of BESS

* Pricing Variables

BESS_cost BESS investment cost [Eur]

Tot_cost Total costs [Eur]

Positive Variables P_BESS_chg, P_BESS_dis, P_BESS_max;

Binary Variables

chg_BESS(n,t) Prevent BESS is charging and discharging at same time

;

***********************************EQUATIONS************************************

Equations

Max_Chg_Power_BESS(n,t) Maximum charging power of BESS allowed

Max_Dis_Power_BESS(n,t) Maximum discharging power of BESS allowed

Power_BESS(n,t) BESS power balance

Power_Balance(n,t) System power balance

StateofCharge_BESS_1(n,t) State of Charge of BESS t=1

StateofCharge_BESS_2(n,t) State of Charge of BESS t>1

* Objective Function

BESS_invest_cost BESS investment cost

Total_Cost Total costs for charging

;

Max_Chg_Power_BESS(n,t) .. P_BESS_chg(n,t) =l= chg_BESS(n,t) * P_BESS_max(n) ;

Max_Dis_Power_BESS(n,t) .. P_BESS_dis(n,t) =l= (1-chg_BESS(n,t)) * P_BESS_max(n) ;

Power_BESS(n,t) .. P_BESS(n,t) =e= ((1/eff_BESS_dis) * P_BESS_dis(n,t) - eff_BESS_chg * P_BESS_chg(n,t)) ;

Power_Balance(n,t) .. sum(b, P_BESS_dis(b,t) - P_BESS_chg(b,t)) =e= sum(bb, P_load(bb,t)) ;

StateofCharge_BESS_1(n,t) .. SoC_BESS(n,t) \$ (ord(t) < t0 ) =e= SoC_BESS_init - P_BESS(n,t) / (60 * E_BESS_max(n)) ;

StateofCharge_BESS_2(n,t) .. SoC_BESS(n,t) \$ (ord(t) >= t0) =e= SoC_BESS(n,t-1) - P_BESS(n,t) / (60 * E_BESS_max(n)) ;

* Objective Functions

BESS_degradation_cost .. BESS_deg_cost =e= (sum(t, sum(n, P_BESS(n,t) * lambda_batt_deg ) ) ) / 60 ;

BESS_invest_cost .. BESS_cost =e= sum(n, E_BESS_max(n)) * cost_BESS_invest ;

Total_Cost .. Tot_cost =e= BESS_deg_cost + BESS_cost ;

***********************************BOUNDARIES***********************************

* Power Boundaries

* BESS Power

P_BESS.fx(n,t) \$ (ord(n) = 1) = 0 ;
P_BESS_chg.fx(n,t) \$ (ord(n) = 1) = 0 ;
P_BESS_dis.fx(n,t) \$ (ord(n) = 1) = 0 ;

* BESS Energy

E_BESS_max.lo(n) = 0.001 ;

SoC_BESS.l(n,t) = SoC_BESS_init ;

SoC_BESS.up(n,t) = SoC_BESS_max ;
SoC_BESS.lo(n,t) = SoC_BESS_min ;

SoC_BESS.fx(n,t) \$ (ord(t) = 1) = SoC_BESS_init ;

***********************************SOLVER***************************************

Model test_1 /all/;

Solve test_1 using minlp minimizing Tot_cost;

My compilation result shows:

** Warning ** The number of nonlinear derivatives equal to zero
in the initial point is large (= 24 percent).
A better initial point will probably help the
optimization.

** An equation in the pre-triangular part of the model cannot
be solved because the pivot is too small.
Adding a bound or initial value may help.

Residual= 0.50000000
Tolerance (Rtnwtr)= 2.00000000E-08

The critical pre-triangular constraints and the variables they are
solved for in solution order:

Equation StateofCharge_BESS_1(1,1440) has been solved with respect to
variable E_BESS_max(1). Value = 0.001
After the last operation the residual is still -0.5

CONOPT time Total 0.051 seconds
of which: Function evaluations 0.008 = 15.7%
1st Derivative evaluations 0.007 = 13.7%

--- DICOPT: Relaxed NLP is infeasible