solve constraint optimization problem

조회 수: 1 (최근 30일)
Hajar Alshaikh
Hajar Alshaikh 2023년 2월 28일
댓글: Torsten 2023년 2월 28일
I want to solve constraint optimization problem :
min||M||^2 , where the norm is the frobinus norm and M is 2×2 matrix =[1 x;x 1+2x]
i wrote like that but i got error
x = optimvar('x');
prob = optimproblem;
M=[1 x;x 1+2*x]
prob.Objective = norm(M,'fro')^2;
prob.Constraints.cons1 = x^2-2*x <=1
prob.Constraints.cons2 = x >=- 1/2;
sol = solve(prob,x)

채택된 답변

Torsten
Torsten 2023년 2월 28일
x = optimvar('x');
prob = optimproblem;
M=[1 x;x 1+2*x];
prob.Objective = norm(M,'fro')^2;
prob.Constraints.cons1 = x^2-2*x <=1;
prob.Constraints.cons2 = x >=- 1/2;
x0.x = 1;
sol = solve(prob,x0)
Solving problem using fmincon. Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
sol = struct with fields:
x: -0.3333
  댓글 수: 2
Hajar Alshaikh
Hajar Alshaikh 2023년 2월 28일
편집: Hajar Alshaikh 2023년 2월 28일
I copied your code and got this message :
Unable to perform assignment because dot indexing is not supported for variables of this type.
Torsten
Torsten 2023년 2월 28일
Then you use an older MATLAB version.
Take a look at your older documentation on how to supply initial values for the solution variables.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by