Solving a nonlinear problem with an imported function in the objective

183 views
Skip to first unread message

Rodolfo Carboni Borrase

unread,
May 30, 2008, 10:29:51 AM5/30/08
to am...@googlegroups.com
Hi, I've been experimenting with a nonlinear code but I can't make it work:

set MCCTT dimen 5;
set MC = setof {(a,b,c,d,e) in MCCTT}(a,b);
param TH {MCCTT} >= 0;
param STK {MCCTT} >= 0;
param SALES {MCCTT} >= 0;

param SALES_TOT := sum{(a,b,c,d,e) in MCCTT} SALES[a,b,c,d,e];

### DECISION VARS ###

var ADJ >= 0, <= 80;
var PRED{(a,b,c,d,e) in MCCTT} = gammadist(ADJ*TH[a,b,c,d,e],STK[a,b,c,d,e]);

### OBJ FUNCTION ###

minimize Prediction_Error:
sum{(a,b) in MC} abs( sum{(a,b,c,d,e) in MCCTT}(PRED[a,b,c,d,e] - SALES[a,b,c,d,e]));


A probability of sale 'TH', a stock level 'STK' and the real sales figure 'SALES' are read from a database, indexed by MCCTT. The variable 'PRED' is set by the imported function gammadist, that returns a sales estimate based on its arguments TH and STK (the function performs a gamma distribution of the probability of sales 'TH' over the available inventory 'STK'). The objective is to minimize the absolute error between the prediction and the real sales figure, and the error is minimized by applying a correction adjustment ADJ to TH before it is passed to the gammadist function.

I've tried using MINOS and SNOPT but they don't seem to even try moving the variable ADJ around. I've also tried eliminating the PRED variable and plugging gammadist() directly into the objective. I've implemented the problem in an excel sheet (using the excel GAMMADIST function) and the excel solver is able to find an optimal solution, but it takes some time, specially setting the spreadsheet up, which doesn't make it a practical solution. I understand the excel solver uses a Generalized Reduced Gradient algorithm, would using a GRG solver with AMPL work? If so, are there any student or trial versions available that I could use to try it out? Should I set the model in another way to make it work with MINOS or SNOPT?

Thanks a lot,

Rodolfo

MINOS output:

ampl: solve;
MINOS 5.51: optimal solution found.
0 iterations, objective 15565
Nonlin evals: obj = 3, grad = 2.

it just leaves the ADJ variable unmodified and reports the value of the objective. I've made sure the gammadist() function is working correctly. 'PRED' is recalculated correctly each time ADJ is modified.

Ronald Menich

unread,
May 30, 2008, 10:52:25 AM5/30/08
to am...@googlegroups.com
Try getting rid of the abs and instead minimizing the sum of squared
errors.

If you really, really need the abs rather than the ssq, then you might
try reformulating with linear variables, one that's constrained to be at
least as large as the difference pred-sales and another that's
constrained to be at least as large as the difference sales-pred, then
minimize the sum of those linear variables.

Rodolfo Carboni Borrase

unread,
May 30, 2008, 11:18:24 AM5/30/08
to am...@googlegroups.com
Thanks Ronald, I just tried stating the objective as:

minimize Prediction_Error:
sum{(a,b) in MC} (sum{(a,b,c,d,e) in MCCTT}(PRED[a,b,c,d,e] - SALES[a,b,c,d,e]))^2;

but still the solver seems to be doing nothing, just evaluating to the starting value of ADJ and then reporting the objective after 0 iterations. I think my problem is that the solver is not evaluating the gammadist function. I just tried a very simplified objective:

var ADJ >= 1, <= 80;
maximize Test:
gammadist(ADJ*0.5,50);

The optimum solution for this would be to make ADJ as big as possible, in this case 80, but the solver leaves the initial value of ADJ unmodified:

ampl: solve;
MINOS 5.51: optimal solution found.

0 iterations, objective 0.4997


Nonlin evals: obj = 3, grad = 2.

ampl: display ADJ;
ADJ = 1

ampl: let ADJ := 4;


ampl: solve;
MINOS 5.51: optimal solution found.

0 iterations, objective 1.9994


Nonlin evals: obj = 3, grad = 2.

ampl: display ADJ;
ADJ = 4

Any ideas? Thanks again,

Rodolfo


-----Mensaje original-----
De: am...@googlegroups.com [mailto:am...@googlegroups.com]En nombre de
Ronald Menich
Enviado el: viernes, 30 de mayo de 2008 16:52
Para: am...@googlegroups.com
Asunto: [AMPL 1810] Re: Solving a nonlinear problem with an imported

yorck

unread,
Jun 2, 2008, 3:49:42 PM6/2/08
to am...@googlegroups.com

just to try it out: use something else than the gammadist function

and or the minimization with a constraint: s.t. ADJ >=0. <= 80;

--
View this message in context: http://www.nabble.com/-AMPL-1809--Solving-a-nonlinear-problem-with-an-imported-function-in-the-objective-tp17560367p17609324.html
Sent from the AMPL mailing list archive at Nabble.com.

Reply all
Reply to author
Forward
0 new messages