# GAMS Support Wiki

### Site Tools

gams:model_a_step_function

# Differences

This shows you the differences between two versions of the page.

 gams:model_a_step_function [2020/05/19 10:43]Lutz Westermann Fix first example and do some formatting gams:model_a_step_function [2020/05/19 10:48] (current)Lutz Westermann Format for second example Both sides previous revision Previous revision 2020/05/19 10:48 Lutz Westermann Format for second example2020/05/19 10:43 Lutz Westermann Fix first example and do some formatting2012/11/12 12:28 support another example for modeling piecewise constant functions (via MIP)2012/10/15 12:39 support make piecewise constant easier to find2007/12/15 09:02 Franz Nelissen 2007/12/15 06:47 Franz Nelissen created 2020/05/19 10:48 Lutz Westermann Format for second example2020/05/19 10:43 Lutz Westermann Fix first example and do some formatting2012/11/12 12:28 support another example for modeling piecewise constant functions (via MIP)2012/10/15 12:39 support make piecewise constant easier to find2007/12/15 09:02 Franz Nelissen 2007/12/15 06:47 Franz Nelissen created Line 57: Line 57: Set p /1*5/; Set p /1*5/; - * interception ​points of piecewise constant function + Parameter intercept(p) Interception ​points of piecewise constant function - Parameter ​intercept(p) + / 1  10, 2  20, 3  25, 4  30, 5  40 / - / + value(p) ​    Value of piecewise constant function for arguments right of intercept(p) - 1 10 + ​/ 1  10, 2  20, 3  ​10, ​4   0, 5 -10 /; - 2 20 + - 3 25 + - 4 30 + - 5 40 + - /; + - * value(p) is value of piecewise constant function for arguments right of intercept(p) + * We model f(x) = value(p) for x such that p <= 4 and intercept(p) <= x <= intercept(p+1) or intercept(5) <= x - Parameter value(p) + * Note, that f(x) is not well defined when x equals to an intercept - / + - 1  10 + - 2  20 + - 3  10 + - 4   0 + - 5 -10 + - / + - + - * we model f(x) = value(p) for x such that p <= 4 and intercept(p) <= x <= intercept(p+1) or intercept(5) <= x + - * note, that f(x) is not well defined when x equals to an intercept + Variable x, f; Variable x, f; + x.lo = intercept('​1'​)+1;​ x.lo = intercept('​1'​)+1;​ x.up = 50; x.up = 50; - Binary Variable z(p)  'indicate ​whether x > intercept(p)';​ + Binary Variable z(p)  'Indicate ​whether x > intercept(p)';​ - Equation e1(p)  'force z(p) to be 1 if x > intercept(p)'​; + Equation ​       e1(p) 'Force z(p) to be 1 if x > intercept(p)'​ - Equation ​e2(p)  'force x(p) to be >= intercept(p) if z(p) is 1'; + e2(p) 'Force x(p) to be >= intercept(p) if z(p) is 1' - Equation ​fdef   ​'define ​value of f in terms of z(p)';​ + fdef  'Define ​value of f in terms of z(p)';​ - Parameter M1(p) 'bigM values for e1'; + Parameter ​      ​M1(p) 'BigM values for e1' - Parameter ​M2(p) 'bigM values for e2'; + M2(p) 'BigM values for e2'; e1(p).. x =l= intercept(p) + M1(p) * z(p); e1(p).. x =l= intercept(p) + M1(p) * z(p);