[AMPL 1809] Solving a nonlinear problem with an imported function in the objective

View: New views
4 Messages — Rating Filter:   Alert me  

[AMPL 1809] Solving a nonlinear problem with an imported function in the objective

by Rodolfo Carboni Borrase :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


[AMPL 1810] Re: Solving a nonlinear problem with an imported function in the objective

by Ronald Menich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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.

-----Original Message-----
From: ampl@... [mailto:ampl@...] On Behalf Of
Rodolfo Carboni Borrase
Sent: Friday, May 30, 2008 10:30 AM
To: ampl@...
Subject: [AMPL 1809] Solving a nonlinear problem with an imported
function in the objective


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.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


Parent Message unknown [AMPL 1811] Re: Solving a nonlinear problem with an imported function in the objective

by Rodolfo Carboni Borrase :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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: ampl@... [mailto:ampl@...]En nombre de
Ronald Menich
Enviado el: viernes, 30 de mayo de 2008 16:52
Para: ampl@...
Asunto: [AMPL 1810] Re: Solving a nonlinear problem with an imported
function in the objective



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.

-----Original Message-----
From: ampl@... [mailto:ampl@...] On Behalf Of
Rodolfo Carboni Borrase
Sent: Friday, May 30, 2008 10:30 AM
To: ampl@...
Subject: [AMPL 1809] Solving a nonlinear problem with an imported
function in the objective


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.





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [AMPL 1809] Solving a nonlinear problem with an imported function in the objective

by yorck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Rodolfo Carboni Borrase wrote:
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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@googlegroups.com
To unsubscribe from this group, send email to ampl-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---
just to try it out: use something else than the gammadist function

and or the minimization with a constraint: s.t. ADJ >=0. <= 80;
LightInTheBox - Buy quality products at wholesale price