File:Opti conti constrained.svg

From Wikimedia Commons, the free media repository

Jump to: navigation, search

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(2009-02-05)

Source

Own work

Author

Guillaume Jacquenot

Permission
(Reusing this image)

See below.


Matlab Logo.png

This chart was created with MATLAB.

Minimisation

\min_{(x,y)\in R^2} (x-1.5)^2+(y-4)^2

such that

		-x          \leqslant 0

		-y          \leqslant 0

		y-4         \leqslant 0

		-2x+y-1     \leqslant 0

		4.5x+y^2-18\leqslant 0

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

I, the copyright holder of this work, hereby publish it under the following licenses:
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

Afrikaans | Alemannisch | Aragonés | العربية | Asturianu | Беларуская | Беларуская (тарашкевіца) | Български | বাংলা | ইমার ঠার/বিষ্ণুপ্রিয়া মণিপুরী | Brezhoneg | Bosanski | Català | Cebuano | Česky | Dansk | Deutsch | Ελληνικά | English | Esperanto | Español | Eesti | Euskara | فارسی | Suomi | Français | Gaeilge | Galego | עברית | Hrvatski | Magyar | Հայերեն | Bahasa Indonesia | Ido | Íslenska | Italiano | 日本語 | ქართული | ភាសាខ្មែរ | 한국어 | Kurdî / كوردی | Latina | Lëtzebuergesch | Lietuvių | 文言 | Македонски | Bahasa Melayu | Malti | Nnapulitano | Plattdüütsch | Nederlands | ‪Norsk (nynorsk)‬ | ‪Norsk (bokmål)‬ | Occitan | Polski | Português | Română | Русский | Slovenčina | Slovenščina | Shqip | Српски / Srpski | Svenska | Kiswahili | తెలుగు | ไทย | Tagalog | Türkçe | Українська | اردو | Vèneto | Tiếng Việt | Volapük | Yorùbá | 中文 | ‪中文(简体)‬ | ‪中文(繁體)‬ | +/−

Creative Commons license
Creative Commons Attribution iconCreative Commons Share Alike icon
This file is licensed under the Creative Commons Attribution ShareAlike 3.0, Attribution ShareAlike 2.5, Attribution ShareAlike 2.0 and Attribution ShareAlike 1.0 License. In short: you are free to share and make derivative works of the file under the conditions that you appropriately attribute it, and that you distribute it only under a license identical to this one. Official license.

Afrikaans | Беларуская | Български | Català | Česky | Dansk | Deutsch | Ελληνικά | English | Esperanto | Español | Eesti | Euskara | Estremeñu | Suomi | Français | עברית | Hrvatski | Հայերեն | Italiano | 日本語 | 한국어 | Lietuvių | Македонски | Plattdüütsch | Nederlands | ‪Norsk (bokmål)‬ | Occitan | Polski | Piemontèis | Português | Română | Русский | Slovenčina | ไทย | Vèneto | Tiếng Việt | 中文 | ‪中文(简体)‬ | ‪中文(繁體)‬ | +/−

You may select the license of your choice.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current22:20, 5 February 2009Thumbnail for version as of 22:20, 5 February 2009512×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)

There are no pages that link to this file.