-
Notifications
You must be signed in to change notification settings - Fork 1
2. Existence of optimal solutions and optimality conditions
Marsha Gómez edited this page May 25, 2023
·
3 revisions
Exercise 1.1. Prove that the quadratic programming problem
close all;
clear;
clc;
matlab.lang.OnOffSwitchState = 1;
Q = [1 0
0 -1];
% The Quadratic Problem is indefinite
eig(Q)
% Objective function
f = @(x1,x2) (1/2).*x1.^2 - (1/2).*x2.^2 + x1 - 2.*x2;
g1 = @(x1,x2) -x1 + x2 <= -1;
g2 = @(x1,x2) -x2 <= 0;
% 3D Surface plot
fsurf(f);
hold on
fsurf(g1);
fsurf(g2);
hold off
Output
% 2D Contour plot
fcontour(f, 'LevelList',1);
hold on
fcontour(g1,'LevelList',1);
fcontour(g2, 'LevelList',1);
hold off
Output