ENDO

<< Click to Display Table of Contents >>

Navigation:  Gekko User Manual > Gekko statements >

ENDO

Previous pageReturn to chapter overviewNext page

ENDO and EXO are used for fixing variables, that is, setting variables to some values (goal), and asking the system to solve this by means of other variables (means). The ENDO statement works differently depending upon option model type (if a model is loaded with the MODEL statement, this option is set automatically).

With option model type = default, ENDO endogenizes a list of variables (without date settings). A model must be defined beforehand.

With option model type = gams, ENDO produces array-series with names starting with endo_. These array-series can subsequently be used to tell e.g. GAMS which variables are fixed and non-fixed. In this case, ENDO must indicate dates.

 

Use UNFIX to remove previously set ENDO or EXO variables.

 


 

Syntax

 

default type:     endo variable1, variable2, ... ;
gams type:        endo <period0> variable1 <period1>, variable2 <period2>, ... ;

 

variables

Default type: The variables are simple series names, or lists of these, for instance x2, or {#m}.

Gams type: The variables are series or array-series names, for instance x2 or x2[a,b]. For array-series, lists may be used, for instance x2[a,#i,#j], where #i and #j are lists of strings.

period0

A period is a Gekko time interval like <2020 2030> or <2020q1 2030q4>. The general period can be set in the period0 field, and this period will be be used for the variables, unless specific periods are given in the period1, period2, etc.

period1, period2, ...

A period is a Gekko time interval like <2020 2030> or <2020q1 2030q4>. These specific periods will overrule the general period (period0).

 

 


 

Examples

 

Gekko type

 

If you need to exogenize a variable fy, and endogenize a variable tg, use this:

 

model forecst;  //Gekko model, will set "option model type = default"
exo fy;         //a list of strings can be used, for instance {#m}
endo tg;
sim <fix>;      //option <fix> must be used to enforce the goals/means.

 

Gams type

 

The following example exogenizes variables x1[a,k1] and y1, and endogenizes x2[a,k1] and y2.

 

option model type = gams; //may omit if a MODEL<gms> statement is used first
exo x1[a,k1] <2022 2024>, y1 <2024 2026>;       //or: x1['a', 'k1']
endo <2023 2025> x2[a,k1] <2021 2023>, y2;      //or: x2['a', 'k1']
prt <2020 2027 width=20 n> exo_x1, exo_y1, endo_x2, endo_y2;

 

The resulting variables are as follows (note that these variables are overwritten if they exist beforehand):

 

 
              exo_x1[a, k1]                exo_y1        endo_x2[a, k1]               endo_y2
 2020                     M                     M                     M                     M
 2021                     M                     M                1.0000                     M
 2022                1.0000                     M                1.0000                     M
 2023                1.0000                     M                1.0000                1.0000
 2024                1.0000                1.0000                     M                1.0000
 2025                     M                1.0000                     M                1.0000
 2026                     M                1.0000                     M                     M
 2027                     M                     M                     M                     M

 

Instead of individual elements, you may use lists:

 

option model type = gams; //may omit if a MODEL<gms> statement is used first

#= a1, a2;
#= k1, k2;
exo <2022 2024> x1[#a,#k];
endo <2021 2023> x2[#a,#k];
prt <2020 2025 width=20 split n> exo_x1, endo_x2;

 

The two lists are automatically unfolded into 2 x 2 = 4 elements (sub-series) regarding exo_x1 and endo_x2:

 

             exo_x1[a1, k1]        exo_x1[a1, k2]        exo_x1[a2, k1]        exo_x1[a2, k2] 
  2020                     M                     M                     M                     M 
  2021                     M                     M                     M                     M 
  2022                1.0000                1.0000                1.0000                1.0000 
  2023                1.0000                1.0000                1.0000                1.0000 
  2024                1.0000                1.0000                1.0000                1.0000 
  2025                     M                     M                     M                     M 
 
             endo_x2[a1, k1]       endo_x2[a1, k2]       endo_x2[a2, k1]       endo_x2[a2, k2] 
  2020                     M                     M                     M                     M 
  2021                1.0000                1.0000                1.0000                1.0000 
  2022                1.0000                1.0000                1.0000                1.0000 
  2023                1.0000                1.0000                1.0000                1.0000 
  2024                     M                     M                     M                     M 
  2025                     M                     M                     M                     M 

 

 


 

Notes

 

With a Gekko model, the ENDO and EXO statements are non-cumulative, so all endogenized/exogenized variables should be present in the same ENDO/EXO statement.

 

With a GAMS model, the ENDO and EXO statements are cumulative in the sense that ENDO or EXO do not delete existing endo_... and exo_... array-series.

 


 

Related options

 

option model type = default;

 


 

Related statements

 

EXO, SIM, UNFIX