Assignment title: Information
49928: Design Optimisation and Manufacturing
Question 1 and Question 3 are selected.
Solution to Question 1
Mathematical model:
The variables are defined as …..
The objective function is … because …
The constraints are … because…
So the mathematical model of the problem is …
Graphical solution:
By using MATLAB code Question 1.m, the following graph can be obtained. In the graph, the black lines are …. The red line is … the green line is ….
The optimal solution is around red circle. Its values are …. The objective function value is …
The constraints values are … so all the constraints are satisfied.
Changing the parameter:
I have decided to change the profit of the table from $20 each into $18 each. The following is the new model and the new solution….
Discussions.
When the profit of table is reduced, …
Solution to Question 3
Similar to that for Question 1……
MATLAB code for Question 1:
% Student name, student ID
% Question 1 for Assignment 1
% Some changes made for improving user interface
% (1) The font size is enlarged – see Line ?? 'fontsize',12
% (2) The line width is enlarged – see Line ?? 'linewidth',2
% Mathematical model:
% minimize f: 12*x1+2*x2
% subject to h: 2*x1 – 3* x2/4 <=10
% g: 2*x1-x2<=0
% 6<=x1<=9; 5<=x2<=20;
close all
clear
% function []=ex1_3(x3)
% Example 1.3 in the text book, P15
x3=5;
s=20;
x1L=0; x1U=15; s1=(x1U-x1L)/s; % set the step
x2L=0; x2U=10; s2=(x2U-x2L)/s;
[x1,x2]=meshgrid(x1L:s1:x1U,x2L:s2:x2U); % transforms the domain specified by vectors x and y into arrays X and Y
f=18*55*x1+18*50*x2+21*50*x3; % ******* Objective function
[C,H]=contour(x1,x2,f,'k'); % compute a single contour at the level v
clabel(C,H);
hold on; grid on;
axis ([x1L x1U x2L x2U])
xlabel('x1','fontsize',12);
ylabel('x2','fontsize',12);
title('Objective function - Press ANY key to continue','fontweight','bold','fontsize',12); pause;
g1=400000*x1+600000*x2+700000*x3; % ******* inequality constraint 1
[Cg1,Hg1]=contour(x1,x2,g1,[12000000,12000000],'r');
clabel(Cg1,Hg1,'fontweight','bold');
set(Hg1,'linewidth',2);
title('Constraint g1 - Press ANY key to continue','fontweight','bold','fontsize',12);
pause;
g2=3*x1-x2+x3; % ******* inequality constraint 2
[Cg2,Hg2]=contour(x1,x2,g2,[30,30],'g');
clabel(Cg2,Hg2);
set(Hg2,'linewidth',2);
title('Constraint g2 - Press ANY key to continue','fontweight','bold','fontsize',12);
pause;
g3=3*x1+6*x2+6*x3; % ******* inequality constraint 3
[Cg3,Hg3]=contour(x1,x2,g3,[100,100],'m');
clabel(Cg3,Hg3);
set(Hg3,'linewidth',2);
title('Constraint g3 - Press ANY key to continue','fontweight','bold','fontsize',12);
pause;
% find the optimal solution
title('Point mouse to optimal solution','fontweight','bold','fontsize',12);
[x1o,x2o]=ginput(1);
plot(x1o,x2o,'r+','markersize',20);
plot(x1o,x2o,'ro','markersize',10,'linewidth',3);
fo=18*55*x1o+18*50*x2o+21*50*x3;
g1o=400000*x1o+600000*x2o+700000*x3;
g2o=3*x1o-x2o+x3;
g3o=3*x1o+6*x2o+6*x3;
if ~(g1o>12000000 | g2o>30 | g3o>100),
title(sprintf('x1o=%-4.2f x2o=%-4.2f fo=%-4.2f',x1o,x2o,fo),'fontweight','bold','fontsize',12);
else
title('Constraint failed','fontweight','bold','fontsize',12);
end;
MATLAB code for Question 3:
% Student name, student ID
% Question 3 for Assignment 1
% Some changes made for improving user interface
% (1) The font size is enlarged – see Line ?? 'fontsize',12
% (2) The line width is enlarged – see Line ?? 'linewidth',2
%
% Mathematical model:
% minimize f:C*pi*x1*x2
% subject to h:pi*x1^2*x2/4-500=0
% g:2*x1-x2<=0
% 6<=x1<=9; 5<=x2<=20;
%change these parameters as desired
close all % close all the open figure windows
clear all % removes all variables, globals and functions from memory
step=0.1; % set the step size
Co=1/10000; % cost parameter: 1 dollar per cm^2
x1L=6; x1U=9; % side constraints of d (x1) and h (x2)
x2L=5; x2U=20; % h
[x1,x2]=meshgrid(x1L:step:x1U,x2L:step:x2U);
% transforms the domain specified by vectors
% x and y into arrays X and Y that can be used for the evaluation
% of functions of two variables and 3-D surface plots.
% The rows of the output array X are copies of the vector x and
% the columns of the output array Y are copies of the vector y
f=Co*pi*x1.*x2; % Objective function
h=pi*x1.^2.*x2/4-500; % Equality constraint
g=2*x1-x2; % inequality constraint
figure('numbertitle','off','name','Ex1_1'); % display the figure name
[C,H]=contour(x1,x2,f,'color','k'); % plot the contour of the objective function
% returns contour matrix C as described in
% CONTOURC and a handle H to a contourgroup object. This handle can
% be used as input to CLABEL
clabel(C,H); % adds height labels to the current contour plot
hold on; grid on; % keep the setting of the current plot
xlabel('x1','fontsize',12);
ylabel('x2','fontsize',12);
title('Objective function - Press ANY key to continue','fontweight','bold','fontsize',12);
pause;
% equality constraint
[Ch,Hh]=contour(x1,x2,h,[0,0],'y');
clabel(Ch,Hh);
set(Hh,'linewidth',6); % set the value of specified property for the graphics object with handle H
title('Equality constraint - Press ANY key to continue','fontweight','bold','fontsize',12);
pause;
% inequality constraint
[Cg,Hg]=contour(x1,x2,g,[0,0],'b');
clabel(Cg,Hg);
set(Hg,'linewidth',4);
title('Inequality constraint - Press ANY key to continue','fontweight','bold','fontsize',12);
pause;
% pick the optimal solution
title('Point mouse to optimal solution','fontweight','bold','fontsize',12);
[x1o,x2o]=ginput(1);
plot(x1o,x2o,'r+','markersize',20); % plot vector y versus vector x
plot(x1o,x2o,'ro','markersize',10,'linewidth',3);
fo=Co*pi*x1o*x2o;
ho=pi*x1o.^2.*x2o/4-500;
go=2*x1o-x2o;
if abs(ho)<10 & go<0
title(sprintf('x1o=%-4.2f x2o=%-4.2f fo=%-4.5f',x1o,x2o,fo),'fontweight','bold','fontsize',12);
else
title('Constraint failed','fontweight','bold','fontsize',12);
end;