function [y,it]=penalta_reseni(dtheta,ddtheta,x0,tol,rho0)
%[y,it]=penalta_reseni(theta,dtheta,x0,tol,rho)
%
% Metoda kvadraticke penalty pro reseni ulohy 
%
% min f(x) 
%  s omez. 
%  h(x)<=0
%
% Tato uloha je prevedena na ulohu min theta(x), 
% kde theta(x) = f(x) + 1/2*rho*(max{0,h(x)})^2
%
%  y       ... minimum
%  it      ... pocet iteraci
%
%  theta   ... minimalizovana fce theta(x) = f(x) + 1/2*rho*(max{0,h(x)})^2 
%  dtheta  ... gradient minimalizovane fce dtheta(x)= 
%                  = grad f(x) + rho*(max{0,h(x)})'*grad (max{0,h(x)})
%  x0      ... pocatecni iterace
%  tol     ... presnost reseni
%  rho0     ... velikost penalty

global rho m
rho=rho0;

m = 1; %2; 3; 4; 5; 10;

[y,it]=newton_reseni(dtheta,ddtheta,x0,tol);

figure
hold on
axis([-0.7 2.2 -2.2 0.2])
fill([-0.5,1,2,2,-0.5],[-0.5,-2,-1,-2.2,-2.2],'r');
line([0,y(1)],[0,y(2)],'Color', 'k', 'LineWidth',2); plot(y(1),y(2),'o','MarkerSize',10,'MarkerFaceColor','k');
plot(0,0,'+','Color', 'k','MarkerSize',12);

% konec


