The results about NaN

30 views
Skip to first unread message

MK

unread,
Sep 8, 2018, 12:34:42 PM9/8/18
to YALMIP
Dear sir,
   
          I have got the object value to be NaN when i using fmincon to solve a convex problem.

          I guess it's the numerical problem caused by log function, but i have no idea to sovle it. And i have avoid the division and multiply in the log function.
          
          Some variables and parameters may be too small or big in the log function, is there any way to avoid this? For example, there are some skills that getting it balance?

          The following is my code. 

          Any help would be greatly appreciated.

          Thanks for your time.
cons_p1_matrix.m
test1.m

Johan Löfberg

unread,
Sep 8, 2018, 12:51:08 PM9/8/18
to YALMIP
Code does not run. Add clear all on top of it and make sure it runs before reposting

MK

unread,
Sep 8, 2018, 1:03:37 PM9/8/18
to YALMIP
I am sorry, sir.

I have changed it as you said.

Thanks a lot.
obj.m
cons_p1_matrix.m
test1.m

Johan Löfberg

unread,
Sep 8, 2018, 1:08:54 PM9/8/18
to YALMIP
Well, fmincon doesn't even start here, is that what you are talking about?

result_p1 = 

  struct with fields:

      yalmiptime: NaN
      solvertime: NaN
            info: 'Unknown problem in solver (Turn on 'debug' in sdpsettings) (Error using barrier↵Nonlinear constraint function is undefined at initial point. Fmincon cannot continue.)'
         problem: 9
    solveroutput: []

>> result_p1 = optimize(cons_p11, obj(kexi),sdpsettings('debug',1))
Your initial point x0 is not between bounds lb and ub; FMINCON
shifted x0 to strictly satisfy the bounds.

Error using barrier
Nonlinear constraint function is undefined at initial point. Fmincon cannot
continue.



To get anywhere on this model, you will have to supply an initial guess

MK

unread,
Sep 8, 2018, 1:36:07 PM9/8/18
to YALMIP
Seems something goes wrong, i will go to check it.

Thanks a lot, sir.

Johan Löfberg

unread,
Sep 8, 2018, 2:07:18 PM9/8/18
to YALMIP
the message here is very clear. fmincon will not be able to solve unless you provide an initial feasible guess. nothing wrong

Johan Löfberg

unread,
Sep 8, 2018, 2:17:03 PM9/8/18
to YALMIP
you should also take the time to simplify your code. you are doing a lot of unnecessarily slow for-loops. you can write p_u <= p_user_max etc, and this

 tmp1 = 0;
    tmp2 = 0;
    tmp3 = 0;
    for i = 1 : N
        tmp1 = tmp1 + a_u(i) * alpha_u(i,t);    
        tmp2 = tmp2 + a_d(i) * alpha_d(i,t);
        tmp3 = tmp3 + a_d(i) * p_d(i,t);
    end
    const = [const; tmp1 <= 1; tmp2 <= 1; tmp3 + p_s(t) <= p_uav_max];

is simply const = [const, a_u*alpha_u <= 1, a_d*alpha_d <= 1, a_d*p_d + p_s' <= p_uav_max]


Reply all
Reply to author
Forward
0 new messages