|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
[AMPL 1809] Solving a nonlinear problem with an imported function in the objectiveHi, 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 objectiveTry 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 objectivejust to try it out: use something else than the gammadist function and or the minimization with a constraint: s.t. ADJ >=0. <= 80; |
| Free Forum Powered by Nabble | Forum Help |