Commit 9deaa019 authored by Saad Jbabdi's avatar Saad Jbabdi
Browse files

added Jesper's optimisation pracs

parent 701f86f4
This diff is collapsed.
# Optimisation practical
Open `OptPractical.m` in matlab and follow the instructions.
\ No newline at end of file
function refresh_peaks(x,y,xp,yp)
clf;
z = 3 * (1-x).^2 .* exp(-(x.^2) - (y+1).^2) - 10 * (x/5 - x.^3 - y.^5) .* exp(-x.^2 - y.^2) - 1/3 * exp(-(x+1).^2 - y.^2);
surfc(x,y,z,'EdgeColor',[.5 .5 .5]);
xlabel('x');
ylabel('y');
hold on;
zp = 3 * (1-xp).^2 .* exp(-(xp.^2) - (yp+1).^2) - 10 * (xp/5 - xp.^3 - yp.^5) .* exp(-xp.^2 - yp.^2) - 1/3 * exp(-(xp+1).^2 - yp.^2);
plot3(xp,yp,zp,'ro','MarkerSize',8,'MarkerFaceColor','r','MarkerEdgeColor','k','LineWidth',2);
return
function refresh_rosenbrock(x,y,lcm,pp)
rosen = (1-x).^2 + 100*(y-x.^2).^2; % Function values on grid
clf;
surfc(x,y,rosen,'EdgeColor',[.5 .5 .5]);
xlabel('x');
ylabel('y');
colormap(lcm);
axis([-1.5 2 -1 3 -200 2500]);
view(-28,30);
hold on;
xm=1; ym=1; fm=(1-xm).^2 + 100*(ym-xm.^2).^2;
plot3(xm,ym,fm,'ro','MarkerSize',12,'MarkerFaceColor','r','MarkerEdgeColor','k','LineWidth',3);
for i=1:size(pp,2)
fp=(1-pp(1,i)).^2 + 100*(pp(2,i)-pp(1,i).^2).^2;
plot3(pp(1,i),pp(2,i),fp,'ro','MarkerSize',8,'MarkerFaceColor','b','MarkerEdgeColor','k','LineWidth',2);
end
function refresh_sse(beta1,beta2,sse,lcm,b)
clf;
surfc(beta1,beta2,sse,'EdgeColor',[.5 .5 .5]);
xlabel('b1');
ylabel('b2');
view(-70,52);
axis([3 6 -0.05 0.2 0 4000]);
colormap(lcm);
hold on
plot3(b(1),b(2),b(3),'ro','MarkerSize',12,'MarkerFaceColor','b','MarkerEdgeColor','k','LineWidth',2);
return
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment