problems about solve exponential function

7 次查看(过去 30 天)
Hi fellows, I have been posted a lot of question for my optimization problem and so far I am still stuck in the place. I think it might be that I haven't explain things precisily. I will try this time.
I have a funciton called beta (which is likely to be an unsmooth one) needed to be optimized. I have tried to use fmincon, and by limit the iterations number to 4 I get a really nice result for once. But the strange thing is that if I run the exactly codes in another computerm it always gives me error message as bellow
>> main
sumllh =
523.7087
sumllh =
523.7087
sumllh =
523.7087
sumllh =
523.7087
Warning: Explicit solution could not be found. > In solve at 169 In maxmin0 at 142 In maxmin at 15 In beta at 18 In C:\Program Files\MATLAB\R2012a\toolbox\shared\optimlib\finDiffEvalAndChkErr.p>finDiffEvalAndChkErr at 26 In C:\Program Files\MATLAB\R2012a\toolbox\shared\optimlib\finitedifferences.p>finitedifferences at 128 In C:\Program Files\MATLAB\R2012a\toolbox\optim\optim\private\computeFinDiffGradAndJac.p>computeFinDiffGradAndJac at 28 In C:\Program Files\MATLAB\R2012a\toolbox\optim\optim\barrier.p>barrier at 135 In fmincon at 841 In main at 6 Error using mupadmex Error in MuPAD command: Subscripted assignment dimension mismatch
Error in sym/subsasgn (line 1638) C = mupadmex('symobj::subsasgn',A.s,B.s,inds{:});
Error in maxmin0 (line 142) y5(i)=solve(f5,x);
Error in maxmin (line 15) [PF0,eu0]=maxmin0(sub,DD);
Error in beta (line 18) mu = maxmin(sub,DD);
Error in C:\Program Files\MATLAB\R2012a\toolbox\shared\optimlib\finDiffEvalAndChkErr.p>finDiffEvalAndChkErr (line 26)
Error in C:\Program Files\MATLAB\R2012a\toolbox\shared\optimlib\finitedifferences.p>finitedifferences (line 128)
Error in C:\Program Files\MATLAB\R2012a\toolbox\optim\optim\private\computeFinDiffGradAndJac.p>computeFinDiffGradAndJac (line 28)
Error in C:\Program Files\MATLAB\R2012a\toolbox\optim\optim\barrier.p>barrier (line 135)
Error in fmincon (line 841) [X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in main (line 6) [x,fval,exitflag,output,lambda,grad] = fmincon(@beta,[0.21,0.2,0.2,0.01,20,0.1,20,0.1],A,b,[],[],lb,ub,[],options)
and this the the related code for the error
if true
%syms x
f5=simplify(p1*coef1*exp(-r*coef1*x)+p2*coef2*exp(-r*coef2*x)+p3*coef3*exp(-r*coef3*x));
y5(i)=solve(f5,x);
if (isempty(y5(i))==1)
pf5(1,i)=0;
else
pf5(1,i)=double(y5(i));
end
pf5(2,i)=(d1(i,1)-d1(i,3))*pf5(1,i)/(d2(i,3)-d2(i,1));
end
and you may notice that I add a if sentence to test isempty here. It is because some of you suggest that it may be the case there is not an explicit solution for f5. So I add an test isempty to solve this problem. But it is very depressing the program still shows the same error message.
I am really confused with my problem...I just don't understand where things is wrong...I really hope you can offer some advice.
  1 个评论
xueqi
xueqi 2013-2-18
I used to think it is the case that only 2012 version gives my this error message. But this weekend I find in my laptop which is 2010 version it still gives me the similar error. The thing I have changed is the intial value in fmincon. I don't know if this is the problem...

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by