Asked by Maryamm Bodaghi
on 16 Aug 2014

excuse me, how can set a tolerance? because I want to solve this:( I mean finding "cc" which satisfies below)

* F(cc)<=min(F(c))+(0.5)^k *

and k k is iteration number. in paper, writer said that tolerance should be set on "(0.5)^k". I've written a az below,but it doesn't work.

objfcn = @(cc) fmp_cmp(cc, Uu, Cc, mm, p); options = optimset('TolFun', delta^k); A = [ones(1,24)]; b =[1]; cc0=rand(1,24); cc0=cc0/sum(cc0); [cc,fval]=fmincon(objfcn,cc0,[],[],A,b,zeros(1,24),ones(1,24),options);

*No products are associated with this question.*

Answer by Matt J
on 16 Aug 2014

Edited by Matt J
on 16 Aug 2014

There may be a typo in your post. The additive constant `(0.5)^k` doesn't affect the solution in any way. `cc=argmin(F)` is a solution for all k. Perhaps you really meant to write an equality,

F(cc)=min(F)+(0.5)^k

If so, the first step is to minimize F() as I think you have done in other posts. If Fmin is this minimum, then the above reduces to

Fmin+(0.5)^k -F(cc)=0

You could indeed use `fminsearch` to solve this nonlinear equality

cc=fminsearch(@(cc) abs(Fmin+(0.5)^k -F(cc)) ,...)

However, it would be more direct to use `fzero`

cc = fzero(@(cc) Fmin+(0.5)^k -F(cc) ,...)

Show 1 older comment

Maryamm Bodaghi
on 17 Aug 2014

thanks Dear Matt;

I'me trying to do your advice, but it doesn't accepr vector.

it=1; mm=1; p=1e-9; delta=0.5; eta=10^(-6);

c=sdpvar(1,24) const=[0<=c<=1,sum(c)==1];

function F_m_p_cmp=fmp_cmp(F_m_p_c,it,cc, Uu, Cc, mm, p) for ii=1:mm for t=1:24 ex(ii,t)=1*(cc(t)*((log(1-(1./(Uu(1,t,mm)+Cc(1,t,mm)))))+(log(1-(1./(Uu(2,t,mm)+Cc(2,t,mm)))))+... (log(1-(1./(Uu(2,t,mm)+Cc(2,t,mm))))))); end end expp=p*ex; eexp=exp(-1*expp); F_m_p_cmp=(1/p)*log10(sum(sum(eexp))); fmp_cmp=F_m_p_c+(0.5)^it-F_m_p_cmp end

for ii=1:mm for t=1:24 ex(ii,t)=-1*(c(t)*((log(1-(1./(Uu(1,t,mm)+Cc(1,t,mm)))))+(log(1-(1./(Uu(2,t,mm)+Cc(2,t,mm)))))+... (log(1-(1./(Uu(2,t,mm)+Cc(2,t,mm))))))); end end expp=p*ex; eexp=exp(expp); F_m_p_c=(1/p)*log(sum(sum(eexp)));

solvesdp(const,-F_m_p_c)

double(F_m_p_c) c=double(c) objfcn = @(cc) fmp_cmp(F_m_p_c,it,cc, Uu, Cc, mm, p) cc = fzero(objfcn,[0 1])

cc should be a 1x24 vector

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments