Error: Parameters are currently only allowed to enter function such as exp, sin etc as exp(a), sin(b) etc.

182 views
Skip to first unread message

Muhammad Shahzad

unread,
Feb 25, 2020, 7:25:33 AM2/25/20
to YALMIP

u = sdpvar(repmat(nu,1,N),repmat(1,1,N));
y_pred = (sdpvar(repmat(nx,1,N),repmat(1,1,N)))';
r = (sdpvar(repmat(ny,1,N),repmat(1,1,N)))';

constraints = [];
objective = 0;

for k = 1:N
 %x = A*x + B*u{k};
 y_pred{k} = simlssvm({input_train',output_train',type,6965.92075677792,0.0272260740857455,'RBF_kernel','orignal'},{alpha_pso,b_pso},u{k}');
 
 objective = objective + norm(y_pred{k}-(r{k}),1) + norm(R*u{k},1);
 constraints = [constraints, -1 <= u{k}<= 1 , -1 <=y_pred{k} <= 1];
end


%%         Now Implementation   %%
parameters_in = {[r{:}]};
solutions_out = {[u{:}], [y_pred{:}]};

controller = optimizer(constraints, objective,sdpsettings('solver','gurobi'),parameters_in,solutions_out);
%controller = optimizer(constraints, objective,[],[],[u{:}]);

Muhammad Shahzad

unread,
Feb 25, 2020, 11:47:15 AM2/25/20
to YALMIP
If i use "fmincon" instead of Gurobi then following error occurs:

Error using ldl
Out of memory. Type "help memory" for your options.

Error in formAndFactorKKTmatrix

Error in formAndFactorKKTmatrix

Error in computeTrialStep

Error in barrier

Error in fmincon (line 813)
    [X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
    barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...

Error in callfmincon (line 91)
[xout,fmin,flag,output,lambda] =
fmincon('fmincon_fun_liftlayer',model.x0,model.A,model.b,model.Aeq,model.beq,model.lb,model.ub,callback_con,model.options.fmincon,model);

Error in optimizer/subsref (line 326)
                eval(['output = ' self.model.solver.call '(self.model);']);

Johan Löfberg

unread,
Feb 25, 2020, 1:20:38 PM2/25/20
to YALMIP
answered on the wiki 

(cannot use simlssvm with yalmip objects)

Muhammad Shahzad

unread,
Feb 25, 2020, 1:28:19 PM2/25/20
to YALMIP
Thank you, sir, I have changed "gurobi" to "fmincon" by using []. And reduced horizon from N=7 to N=2. now it's working but took a long time to run, even it's more than an hour, still, simulation is in progress.
N=2; what other option can i use please?

%%         Now Implementation   %%

parameters_in = {[r{:}]};

solutions_out = {[u{:}]};

controller = optimizer(constraints, objective,[],parameters_in,solutions_out);

implementedU = [];
for j =1 : 10
    
    y_reff = sin(y_red(j:j+1));
    U = controller{y_reff};
    implementedU = [implementedU;U(1)];
end

Johan Löfberg

unread,
Feb 25, 2020, 1:44:51 PM2/25/20
to YALMIP
it shouldn't work. If it appears to work, that's just a fact from the fact that optimizer assumes that the user defines a model which can be handled yalmip once the parameters are fixed, and if it doesn't the behavior is undefined

Muhammad Shahzad

unread,
Feb 25, 2020, 1:51:45 PM2/25/20
to YALMIP
thank you so much I understand now. Please suggest that is there any other alternative to apply MPC on problems like this?

Johan Löfberg

unread,
Feb 25, 2020, 1:58:12 PM2/25/20
to YALMIP
You baically have to solve black-box optimization problems (or sit down and derive the derivatives etc of your predictions), and then solve your favorite nonlinear solver. In other words, there is no good convenient way

Muhammad Shahzad

unread,
Feb 25, 2020, 2:02:25 PM2/25/20
to YALMIP
thankyou so much for your guidance sir.
Reply all
Reply to author
Forward
0 new messages