I am modelling a consumer model, but i don’t know how to write this type of equation . Kindly help me out with the equation writing. yours valuable suggestions, comments and help are welcomed. I am attaching the .gms file (code) and JPG file (equations) for the reference. Kindly help me out.

You have functions U1/2/3(x) that have two different algebra parts for different argument ranges.You are already in the NLP domain (because of log) so you can just use the GAMS function ifthen (https://www.gams.com/latest/docs/UG_Parameters.html#INDEX_functions_22_ifThen) to model this. For example, U2(x) = ifthen(x>0, beta*log(omega*x+1), 0). Please note that GAMS evaluates all three parts of the ifthen function independent of the condition in the first argument. That means, if you write it like I just did you will get function evaluation errors with x<-1/omega because then GAMS tries to apply the log function to a negative number. You can avoid this and don’t change the overall outcome of the expression by e.g. writing U1 as ifthen(x>0, beta*log(omega*abs(x)+1), 0).

Hope this helps,

-Michael

Thank you so much for the reply. I can now evaluate U2,U3, but I am getting error for writing U.1 would u kindly review it. I am attaching .gms file for the review, also there are two parts of U1 with 3 bounds. Kindly help me out.

Customer profit maximization.gdx (2.11 KB)

You sent a GDX file. Nothing I can do with this. -Michael

My mistake, unfortunately I uploaded the .gdx file. I have attached now the .gms file and my problem formulation (JPG file) for the reference. Kindly review it and where do I have to write this gaama (sqr(omega)/2*alpha) part.- Line 200

GAMS requires operators between all parts of the expression. In papers for multiplication the ‘*’ sign is often left out. You need that in GAMS (and many other languages):

```
parameter U1;
U1(t)= ifthen(Q1(t)<=omega/alpha, gaama*(omega*Q1(t) -alpha/2*sqr(Q1(t))), omega/alpha);
```

-Michael

In Equation 2, there are four terms. where to write [gaama*(omeega**2)/(2*alpha)] … where do i have to write this term in my code.

I don’t understand the question. -Michael

where to write the encircled part of the equation in the code. i have attached the JPG file.

In the “else” or false_expression part of the function: ifthen(expression, true_expression, false_expression). -Michael