Search found 125 matches

by dirkse
1 day ago
Forum: Solvers
Topic: Different solutions with MCP and NLP formulation
Replies: 1
Views: 79

Re: Different solutions with MCP and NLP formulation

Renger, Essentially, things work as you were expecting if you use the negative of the objective derivative in the FOC. This is to be expected, since you have a maximization. With min you just use the derivative. So, change: c_foc(d).. -log(P(d)) - 1 - LAMBDA * x(d) - GAMMA =E= 0; to c_foc(d).. log(P...
by dirkse
4 days ago
Forum: Syntax
Topic: Running GAMS in phases
Replies: 3
Views: 141

Re: Running GAMS in phases

Hi, There is a tendency to overuse the word "model" in this area. For example, a GAMS model can be: A bunch of GAMS code stored in a file. A GAMS symbol denoting a collection of equations, e.g. model m / all /; The latter can be solved using the solve statement, but the former isn't something to "so...
by dirkse
1 week ago
Forum: Tools
Topic: Importing data from GMAS to MATLAB
Replies: 3
Views: 170

Re: Importing data from GMAS to MATLAB

It looks like you need to do a filtered read. This is typical. I can't explain it better than already done in the manual: https://www.gams.com/31/docs/T_GDXMRW.html#GDXMRW_RGDX I suggest you read this section completely and thoroughly. Also, in the code you sent, you reuse/reassign U. That makes it ...
by dirkse
1 week ago
Forum: Tools
Topic: Importing data from GMAS to MATLAB
Replies: 3
Views: 170

Re: Importing data from GMAS to MATLAB

It would be best if you showed us the output of your run so we knew exactly what you are getting. Without that, it's hard to say precisely what the issue is. But I'll guess you are confusing full (aka dense) and sparse format. Have a look at the 'form' field in the input structure for rgdx. Try your...
by dirkse
2 weeks ago
Forum: Modeling
Topic: Double bound variable in an MCP
Replies: 2
Views: 194

Re: Double bound variable in an MCP

Tatjana, Let's take a simple MCP as an example. Let's start with an optimization problem, so we have some intuition from the optimization world we can lean on. min f(x) := sqr(x-1) s.t. L <= x <= U, where L and U can be finite or the expected infinity. Taking the KKT conditions we get this MCP: F(x)...
by dirkse
2 weeks ago
Forum: Modeling
Topic: implementation problem
Replies: 4
Views: 385

Re: implementation problem

Danesh, You should not take an equality and make it two inequalities. This is a bad idea computationally. Just use the equality with a free multiplier. You asked me to elaborate, but there's a lot to say. Much of it is spelled out explicitly in the attached kkt.pdf document. In particular, if you re...
by dirkse
3 weeks ago
Forum: Solvers
Topic: Using convert
Replies: 2
Views: 145

Re: Using convert

Oyvind, You don't say what the model type is but since you mention a Hessian I'll guess you're solving an NLP. In this case, your can select the convert solver by the statement option NLP = convert; in your GAMS code. Assuming my guess on the model type was correct, you then solve with SOLVE NLA MAX...
by dirkse
3 weeks ago
Forum: Modeling
Topic: Calculate after getting the optimal solution
Replies: 1
Views: 110

Re: Calculate after getting the optimal solution

Sandy, What you ask about is very easy to do. Outside of a solve statement, a variable is similar to a parameter. You can assign to it, display it and use it in calculations. For example: * setting a level value is good practice for nonlinear models x.L(i) = X0(i); * now solve a model - this changes...
by dirkse
3 weeks ago
Forum: Syntax
Topic: Problem with loop
Replies: 2
Views: 422

Re: Problem with loop

Bingo, You mention CPLEX, but your GAMS code doesn't contain any models or solves. You mention the "break" and "continue" statements, but you don't use those in your GAMS code. So I'm confused as to whether these things are relevant to your question or not. In the code you sent, you don't reset the ...
by dirkse
3 weeks ago
Forum: Modeling
Topic: implementation problem
Replies: 4
Views: 385

Re: implementation problem

Danesh, Several things come to mind. First, are you setting initial values? This is hugely important in nonlinear optimization models, and also for MCP models (linear or not). Looking at your optimization model, you have an equality constraint, but you formulate this as an inequality in the MCP. Thi...