-1

So, i am trying to solve a non linear problem with AMPL and get this error when trying to run. I have multiple objevtives as you can see in the code below, 32 to be precise, since my test parameters are indexed in a set of 32 elements (I). I do not know if the sintax is correct, but at this point i am considering to use for loops or something else so my parameters are one dimensional. I am gratefull for any answer, thanks.

mod:

#Funciones comunes
function gsl_cdf_ugaussian_P;
function gsl_cdf_ugaussian_Pinv;
function gsl_ran_ugaussian_pdf;

#Conjunto
set I;

#Parametros
param alphaL{I};
param h{I};
param S;
param mu{I};
param sigmasq{I};
param L;

#Variables
var Q{I};
var r{I};
var x1{i in I} = (r[i]-mu[i]*L)/(sqrt(sigmasq[i]*L));
var x2{i in I} = (r[i]-mu[i]*L+Q[i])/(sqrt(sigmasq[i]*L));
var H1{i in I} = 1/2*((x1[i]**2+1)*(1-gsl_cdf_ugaussian_P(x1[i]))-x1[i]*gsl_ran_ugaussian_pdf(x1[i]));
var H2{i in I} = 1/2*((x2[i]**2+1)*(1-gsl_cdf_ugaussian_P(x2[i]))-x2[i]*gsl_ran_ugaussian_pdf(x2[i]));
var B{i in I} = (sigmasq[i]*L/Q[i])*(H1[i]-H2[i]);

#Funcion objetivo
minimize Z_alpha{i in I}: S*(mu[i]/Q[i])+h[i]*(Q[i]/2+r[i]-mu[i]*L+B[i]);

#Restricciones
subject to R{i in I}: r[i] >= mu[i]*L+gsl_cdf_ugaussian_Pinv(alphaL[i])*sqrt(sigmasq[i]*L);
subject to Q_EOC{i in I}: Q[i] >= sqrt((2*mu[i]*S)/h[i]);

dat:

set I:= 1..32;
param alphaL:=
    1   0.99
    2   0.99
    3   0.99
    4   0.99
    5   0.95
    6   0.95
    7   0.95
    8   0.95
    9   0.99
    10  0.99
    11  0.99
    12  0.99
    13  0.95
    14  0.95
    15  0.95
    16  0.95
    17  0.99
    18  0.99
    19  0.99
    20  0.99
    21  0.95
    22  0.95
    23  0.95
    24  0.95
    25  0.99
    26  0.99
    27  0.99
    28  0.99
    29  0.95
    30  0.95
    31  0.95
    32  0.95;
param h:=
    1   1.25
    2   1.25
    3   1
    4   1
    5   1.25
    6   1.25
    7   1
    8   1
    9   0.6
    10  0.6
    11  0.1
    12  0.1
    13  0.6
    14  0.6
    15  0.1
    16  0.1
    17  1.25
    18  1.25
    19  1
    20  1
    21  1.25
    22  1.25
    23  1
    24  1
    25  0.6
    26  0.6
    27  0.1
    28  0.1
    29  0.6
    30  0.6
    31  0.1
    32  0.1;
param S:= 250;
param mu:=
    1   200
    2   150
    3   200
    4   150
    5   200
    6   150
    7   200
    8   150
    9   200
    10  150
    11  200
    12  150
    13  200
    14  150
    15  200
    16  150
    17  50
    18  10
    19  50
    20  10
    21  50
    22  10
    23  50
    24  10
    25  50
    26  10
    27  50
    28  10
    29  50
    30  10
    31  50
    32  10;
param sigmasq:=
    1   6400
    2   3600
    3   6400
    4   3600
    5   6400
    6   3600
    7   6400
    8   3600
    9   6400
    10  3600
    11  6400
    12  3600
    13  6400
    14  3600
    15  6400
    16  3600
    17  400
    18  16
    19  400
    20  16
    21  400
    22  16
    23  400
    24  16
    25  400
    26  16
    27  400
    28  16
    29  400
    30  16
    31  400
    32  16;
param L:=2;

2 Answers2

0

I probably would approach this as follows:

#Funcion objetivo
minimize Z_alpha: sum{i in I} w[i]*(S*(mu[i]/Q[i])+h[i]*(Q[i]/2+r[i]-mu[i]*L+B[i]));

Now you can populate the parameter w[i] to select a single objective or a weighted sum objective.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
  • Thanks for your answer, but that's not what i was looking to achieve, i needed to solve for I objectives. Since then i fixed my project, tried 2 ways and both worked just fine. I still don't know why i got this error; since my first approach was to edit my dat file and put all my params in a table, that did the work. And the second approach was to make my mod just for 1 objective (so no indexing vars or params), then iterate with a for cicle replacing parameters each cicle, that also worked just fine. – Killer Potato Jul 29 '21 at 03:19
0

You didn't say what the problem was. Assuming the problem is that your 32 objective functions are not being declared, the problem is with this line of your data file

set I := 1..32;

This line makes I contain a single item: "1..32". That's because in data mode, .. in assignment statements are interpreted as literal strings. You cannot use .. in a data file in the same way you can use it in a model file. I suggest you change the set I declaration in your model file to:

param n;
set I := {1..n};

And initialize n in your data file:

param n = 32;

See solution on PIFOP

Davi Doro
  • 358
  • 2
  • 8