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

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

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 Star Strider
on 16 Aug 2014

Where did ** ‘F’** come from? It’s not in

The `fmincon` function can do that (I’ve not done it myself), but we need to know what your ** F** function is and what you want to do with it (please describe) so we can be sure we can write the constraint function correctly.

Show 6 older comments

Star Strider
on 16 Aug 2014

My pleasure!

* NOTE —* I just discovered what I consider to be a typographical error in the paper. In the paragraph that follows Equation

Equation `(29)` includes Equation `(30)`. The *yh* vector is a parameter vector (defined in `III A.`), and they ambiguously define *‘p’* as ‘some regularization constant’ (just after Equation `(30)`), although they later calculate it in Step `(6)` and Equation `(33)`. Equation `(29)` is actually a double summation, since it includes Equation `(30)`. Step `(4)` updates the estimates for parameter vector ** y**. It seems to me that Equation

So in ** Algorithm 2** it seems to me that you optimise for

This is my impression on a relatively rapid scan of the article. I cannot claim that my outline of it is correct, so discuss this with others closer to the problem to be sure.

Maryamm Bodaghi
on 17 Aug 2014

Dear Star, that's kind of you spending time on reading paper. thank you so much.

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

Matt J
on 16 Aug 2014

**realy I don't have Fmin, because I'm trying to get it,**

But why can't you find Fmin with fmincon? And what effect is 0.5^k supposed to have? It just adds a constant to F(c) without changing the location of its minima.

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

## 0 Comments