Error using barrier Objective function is undefined at initial point. Fmincon cannot continue. Error fmincon (line 848)

I run my main program Train_PF.m. In my main program Train_PF.m , I have declared the initial point u0 as initial point. But there is error said undefined at initial point.
Steps i= 2
Elapsed time is 1.780754 seconds.
Elapsed time is 0.037505 seconds.
Elapsed time is 0.025071 seconds.
Elapsed time is 0.024210 seconds.
Elapsed time is 0.028659 seconds.
Elapsed time is 0.028935 seconds.
Elapsed time is 0.028281 seconds.
Steps i= 3
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 848)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in Train_PF (line 115)
[u, Cost(i,1), Exitflg(i,1), output] = fmincon(@(u) Fungsicos( Np, Tim_step, X0 ,u,
Vehicle_Type,Q1,Xdes,R1,F1,Xa,G1,Xnba), ...

9 comentarios

This is too much for anyone here to take a look at. Try debugging , stop it before it enters i = 3 and look what happens step by step, maybe you made a mistake at indexing somewhere.
But there is error said undefined at initial point.
Do you have some reason to dispute what the error message is telling you? Have you tested the objective function at the initial point u0?
I have declared the initial point u0
In the main program Train_PF
line 55
ua = zeros(Np,Num_veh); % Assumed Braking or Tracking Torque input of each vehicle;
line 62
% Initialzie the assumed state for the first computation: constant speed
for i = 1:Num_veh
ua(:,i) = Torque(1,i);
Pa(1,i) = Postion(1,i); % The first point should be interpreted as k = 0 (current state)
Va(1,i) = Velocity(1,i);
Ta(1,i) = Torque(1,i);
for j = 1:Np
[Pa(j+1,i),Va(j+1,i),Ta(j+1,i)] = traindiscretemodel(ua(j,i),Tim_step,Pa(j,i),Va(j,i),Ta(j,i),Mass(i),Ca_0(i),Ca_1(i),Ca_2(i),Tao(i),R(i),Eta);
end
end
line 105
u0 = ua(:,1);
and in workspace there is u0
this is the contents of u0
-12932.1345678792
30596.4676587217
30596.5703111409
30596.5703117487
30596.5703119381
30596.5703120182
30596.5703120480
30596.5703120420
30596.5703119954
30596.5703118750
30596.5703115299
30596.5703087468
-4477.98446486301
-30596.5703109786
-30596.5703120141
-30596.5703122289
-30596.5703123201
-30596.5703123697
-30596.5703124006
NaN
That's not what I asked, though. I asked if you have tested if the objective function gives a reasonable output when input u0
I;m sorry, I dont quite understand How I tested it?
Have you noticed you have NaN in u0 (last element)?
Actually, his objective function works with this NaN.
He has 7 fmincons that run fine for the first step which is i = 2, in the second step i = 3, this happens.
ok thank you everyone, i will try first to understand the error especially NaN u0
How i change NaN in the workspace? I'm trying to find the meaning error but still confuse. Can anyone help me?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Type Identification en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Etiquetas

Preguntada:

el 9 de Nov. de 2020

Editada:

el 10 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by