From: Luca Zanotti Fragonara on 28 May 2010 05:30 Hello, I'm trying to solve a minimisation problem with fmincon. The only trouble is that I want that one of the parameter of my function should assume only integer value. My code is something like that, where par0S is a vector of parameters. I want the ONE of the value of par0S assumes only integer values. fitness=@(par0S)err_tf_ss_NL(par0S,parmin,parmax,M,disp_meas,vel_meas,acc_meas,inp_meas,f_meas,istante,dt,H,part_path); nonlcon=@(par)mycon(par,max(f_meas),parmin,parmax); [par(:,1), Fob(1,1), flag(1,1)]=patternsearch(fitness,par0S,[],[],[],[],parminS,parmaxS,nonlcon,opt); I thought that in my fitness function err_tf_ss_NL, i could put a "round" on par(ii), if ii is the index that identifies my "integer" parameter. But that seems to not work properly. I think that in this case the fmincon calculates a bad Jacobian matrix, resulting the derivative of fitness respect par(ii) "straigth", but actually it's not: he must calculates the derivative with the next integer value. Do you have any suggestion? Thank you in advance, Luca
From: John D'Errico on 28 May 2010 05:41 "Luca Zanotti Fragonara" <Luca_Zanotti(a)libero.it> wrote in message <hto2fe$drr$1(a)fred.mathworks.com>... > Hello, I'm trying to solve a minimisation problem with fmincon. The only trouble is that I want that one of the parameter of my function should assume only integer value. > > My code is something like that, where par0S is a vector of parameters. I want the ONE of the value of par0S assumes only integer values. > > fitness=@(par0S)err_tf_ss_NL(par0S,parmin,parmax,M,disp_meas,vel_meas,acc_meas,inp_meas,f_meas,istante,dt,H,part_path); > nonlcon=@(par)mycon(par,max(f_meas),parmin,parmax); > [par(:,1), Fob(1,1), flag(1,1)]=patternsearch(fitness,par0S,[],[],[],[],parminS,parmaxS,nonlcon,opt); > > > I thought that in my fitness function err_tf_ss_NL, i could put a "round" on par(ii), if ii is the index that identifies my "integer" parameter. But that seems to not work properly. I think that in this case the fmincon calculates a bad Jacobian matrix, resulting the derivative of fitness respect par(ii) "straigth", but actually it's not: he must calculates the derivative with the next integer value. > > Do you have any suggestion? NO. You cannot round your parameter inside the objective function. Fmincon assumes that your function is a differentiable one. Does this create a differentiable function? NO!!! You cannot use fmincon to solve this problem. Look on the file exchange for an alternative. John
From: Luca Zanotti Fragonara on 28 May 2010 06:42 "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hto33f$m8h$1(a)fred.mathworks.com>... > "Luca Zanotti Fragonara" <Luca_Zanotti(a)libero.it> wrote in message <hto2fe$drr$1(a)fred.mathworks.com>... > > Hello, I'm trying to solve a minimisation problem with fmincon. The only trouble is that I want that one of the parameter of my function should assume only integer value. > > > > My code is something like that, where par0S is a vector of parameters. I want the ONE of the value of par0S assumes only integer values. > > > > fitness=@(par0S)err_tf_ss_NL(par0S,parmin,parmax,M,disp_meas,vel_meas,acc_meas,inp_meas,f_meas,istante,dt,H,part_path); > > nonlcon=@(par)mycon(par,max(f_meas),parmin,parmax); > > [par(:,1), Fob(1,1), flag(1,1)]=patternsearch(fitness,par0S,[],[],[],[],parminS,parmaxS,nonlcon,opt); > > > > > > I thought that in my fitness function err_tf_ss_NL, i could put a "round" on par(ii), if ii is the index that identifies my "integer" parameter. But that seems to not work properly. I think that in this case the fmincon calculates a bad Jacobian matrix, resulting the derivative of fitness respect par(ii) "straigth", but actually it's not: he must calculates the derivative with the next integer value. > > > > Do you have any suggestion? > > NO. You cannot round your parameter inside the > objective function. Fmincon assumes that your > function is a differentiable one. Does this create a > differentiable function? NO!!! > > You cannot use fmincon to solve this problem. > Look on the file exchange for an alternative. > > John Okay, thank you, I was pretty sure that there was no alternative, by the way, thank you again. Luca
|
Pages: 1 Prev: compile lap.cpp Next: blstheta(Price,Strike,Int_Rate,Time,Volatility) |