how to solve a multi-objective nonlinear optimization problem with constraints ?

1 次查看(过去 30 天)
Hello , I have a nonlinear eqt that describes the evolution of my system : dxdt=Ax(t)+Bu(t),with
A=[sqrt(2) 1;2 sqrt(3)]; B=[1 4;3 1]; and u=K1*x+b1. K1 is 2x2 matrix and b1 is 2x1.
I want to find K1 and b1 such that I maximize xdot11 at a point v1 under these constraints :
n1'*B*(K1*v1+b1)+n1'*A*v1<=0;
n4'*B*(K1*v1+b1)+n4'*A*v1<=0;
n1'*xdot11<= 0 ;
K1*v1+b1 <= 2;
K1*v1+b1 >=- 2;
n4'*xdot12<= 0 ;
n1=[0;-1]; n4=[-1;0]
My code is :
clc;
close all;
v1=[80;60];
n1=[0;-1]; n4=[-1;0]; % normal vectors
A=[sqrt(2) 1;2 sqrt(3)];
B=[1 4;3 1];
prob1 = optimproblem;
K1 = optimvar("K1",2,2); % create the optim. variable K1
b1 = optimvar("b1",2,1);
xdot11=((A(1,1)+B(1,1)*K1(1,1)+B(1,2)*K1(2,1))*v1(1))+((A(1,2)+B(1,1)*K1(1,2)+B(1,2)*K1(2,2))*v1(2))+B(1, ...
1)*b1(1)+B(1,2)*b1(2);
xdot21=((A(2,1)+B(2,1)*K1(1,1)+B(2,2)*K1(2,1))*v1(1))+((A(2,2)+B(2,1)*K1(1,2)+B(2,2)*K1(2,2))*v1(2))+B(2, ...
1)*b1(1)+B(2,2)*b1(2);
Obj =-xdot11;
prob1.Objective=Obj
prob1 =
OptimizationProblem with properties: Description: '' ObjectiveSense: 'minimize' Variables: [1×1 struct] containing 2 OptimizationVariables Objective: [1×1 OptimizationExpression] Constraints: [0×0 struct] containing 0 OptimizationConstraints See problem formulation with show.
constr1=n1'*B*(K1*v1+b1)+n1'*A*v1<=0;
constr2=n4'*B*(K1*v1+b1)+n4'*A*v1<=0;
constr3=n1'*xdot11<= 0 ;
constr4=K1*v1+b1 <= 2;
constr5=K1*v1+b1 >=- 2;
constr6=n4'*xdot21<= 0 ;
prob1.Constraints.Constr1=constr1;
prob1.Constraints.Constr2=constr2;
prob1.Constraints.Constr3=constr3;
prob1.Constraints.Constr4=constr4;
prob1.Constraints.Constr5=constr5;
prob1.Constraints.Constr6=constr6;
show(prob1);
OptimizationProblem : Solve for: K1, b1 minimize : -80*K1(1, 1) - 320*K1(2, 1) - 60*K1(1, 2) - 240*K1(2, 2) - b1(1) - 4*b1(2) - 173.1371 subject to Constr1: -240*K1(1, 1) - 80*K1(2, 1) - 180*K1(1, 2) - 60*K1(2, 2) - 3*b1(1) - b1(2) <= 263.923 subject to Constr2: -80*K1(1, 1) - 320*K1(2, 1) - 60*K1(1, 2) - 240*K1(2, 2) - b1(1) - 4*b1(2) <= 173.1371 subject to Constr3: -80*K1(1, 1) - 320*K1(2, 1) - 60*K1(1, 2) - 240*K1(2, 2) - b1(1) - 4*b1(2) <= 173.1371 subject to Constr4: 80*K1(1, 1) + 60*K1(1, 2) + b1(1) <= 2 80*K1(2, 1) + 60*K1(2, 2) + b1(2) <= 2 subject to Constr5: 80*K1(1, 1) + 60*K1(1, 2) + b1(1) >= -2 80*K1(2, 1) + 60*K1(2, 2) + b1(2) >= -2 subject to Constr6: -240*K1(1, 1) - 80*K1(2, 1) - 180*K1(1, 2) - 60*K1(2, 2) - 3*b1(1) - b1(2) <= 263.923
x0.K1=zeros(2);
x0.b1=[1;1];
sol =fsolve(prob1,x0);
Error using fsolve
FSOLVE requires the following inputs to be of data type double: 'X0'.
when I run my code , I get this error :
Unable to perform assignment because dot indexing is not supported for variables of this type.
I tried to solve it with fmincon but it requires to put all of the control variables into one vector x and I didn't know how to define the x0 in this case..
I will be very thankfull for your help.
  7 个评论
Torsten
Torsten 2022-12-18
I must admit that I still don't understand
I want to find K1 and b1 such that I maximize xdot11 at a point v1 under these constraints :
What is v1 ? How does it correspond to something you get from or input into your differential equations ?
tty
tty 2022-12-19
编辑:tty 2022-12-20
my system should evolves inside a rectangle region in my state space and leave the rectangle only from the right edge (line between v2 and v3). this rectangle is specified with four vertices v1,v2,v3 and v4.

请先登录,再进行评论。

采纳的回答

Alan Weiss
Alan Weiss 2022-12-22
For an example that optimizes the solution of an ODE using optimization variables, see Fit ODE Parameters using Optimization Variables. That example shows calling ode45 to solve the ODE, and has an optimization problem built around this ODE solver.
For an entirely different approach, see Discretized Optimal Trajectory, Problem-Based. I don't know if this approach is relevant to your problem.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by