File:Opti conti constrained.svg
From Wikimedia Commons, the free media repository
Opti_conti_constrained.svg (SVG file, nominally 512 × 626 pixels, file size: 145 KB)
[edit] Summary
| Description |
English: Minimisation of a quadratic function under quadratic constraints
Français : Minimisation d'une fonction quadratique sous des contraintes quadratiques
|
|---|---|
| Date |
5 February 2009 |
| Source |
Own work |
| Author | |
| Permission (Reusing this image) |
See below. |
|
This chart was created with MATLAB. |
Minimisation

such that





Unconstrained solution: x = 1.5000,y = 4.0000,funcons = 0.0000
Constrained solution: x = 1.2567,y = 3.5135,fcons = 0.2959
[edit] Source code (MATLAB)
function Opti_conti_constrained clc h = figure; hold on; grid on; box on; axis equal; axis([0 2.5 0 4]+0.05*[-1 1 -1 1]); x = 4/9:0.01:2; hp = plot(x,sqrt(18-4.5*x),... [0.5 2],2*[0.5 2]-1,... [0 4/9],4*[1 1],... [0 0],[0 4],[0 0.5],[0 0]); set(hp,'color',[0 0 0],'LineWidth',2) [X,Y] = meshgrid(0:0.025:2.5,0:0.04:4); Z = (X-1.5).^2+(Y-4).^2; contour(X,Y,Z,50); x0 = [0 0]; A = []; b = []; Aeq = []; beq = []; lb = []; ub = []; options = optimset('Display','iter','LargeScale','off',... 'GradObj','on',... 'Jacobian','off','Hessian','on',... 'TolX',1e-4,'TolFun',1e-4,'TolCon',1e-5,... 'MaxIter',1000,'MaxFunEvals',1e12); [Sol_cons f_cons] = fmincon(@(x) myfun(x),x0,A,b,Aeq,beq,lb,ub,... @(x) constraints(x),options); [Sol_uncons f_uncons] = fminsearch(@(x)(x(1)-1.5)^2+(x(2)-4)^2,[0 0]); plot(Sol_cons(1),Sol_cons(2),'ro') plot(Sol_uncons(1),Sol_uncons(2),'r.') colorbar function [f,g,H] = myfun(x) f = (x(1)-1.5)^2+(x(2)-4)^2; % Compute the objective function value at x if nargout > 1 % fun called with two output arguments g = [2*x(1)-3;2*x(2)-8]; % Gradient of the function evaluated at x if nargout > 2 H = [2 0;0 2]; % Hessian evaluated at x end end function [c,ceq] = constraints(x) c(1,1) = 4.5*x(1)+x(2)^2-18; A = [1 0;0 1;-1 0;0 -1;-2 1]; b = [4;4;0;0;1]; c(2:6,1) = A*x'-b; ceq = [];
[edit] Licensing
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 22:20, 5 February 2009 | 512×626 (145 KB) | Gjacquenot (Talk | contribs) | ({{Information |Description={{en|1=Minimisation of a quadratic function under quadratic constraints}} {{fr|1=Minimisation d'une fonction quadratique sous des contraintes quadratiques}} |Source=travail personnel (own work) |Author=Guillaume Jacquenot [[User) |
- Edit this file using an external application (See the setup instructions for more information)
File links
There are no pages that link to this file.