0% found this document useful (0 votes)
2 views37 pages

Assignment 4

Report

Uploaded by

Arsalan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views37 pages

Assignment 4

Report

Uploaded by

Arsalan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Assignment 4

The Exhaustive Enumeration Method:

The first problem's goal is to limit the supplied function.


F = 2x1 – 6x2 + 3x3 + 4x4 + 7x5 + 3x6 + 2x7
Subjected to constraints:
𝑔1 = 𝑥2 + 5𝑥3 + 3𝑥4 − 𝑥5 + 2𝑥6 + 3𝑥7 ≥ 65
𝑔2 = −6𝑥1 − 3𝑥2 − 2𝑥3 + 𝑥4 + 2𝑥5 − 2𝑥6 ≥ −73
𝑔3 = −7𝑥1 − 4𝑥2 + 3𝑥3 − 4𝑥4 + 3𝑥5 − 2𝑥6 − 𝑥7 ≤ −66
With variable bounds
𝑥1, 𝑥2 ∈ {2,5,7,8},
𝑥3, 𝑥4 ∈ {3,4,6},
𝑥5, 𝑥6 ≥ 0,
𝑥7 ∈R

The code begins by setting the ideal objective function value and the starting values for the decision
variables. Next, it enters a nested loop that iteratively explores every conceivable combination of the
decision variables within their constraints. The code generates the constraints and objective function for
the LP problem and solves it with the linprog () function for each possible value. If the objective function
value of the current solution is smaller than the ideal objective function value, then the code updates
the optimal solution.

Total number of partial nodes = 3*4=1


1) There are four discrete variables [x1, x2, x3, x4] and three continuous variables [x5, x6, x7]
2) Discrete variable final values are determined by loops for continuous variables,
3) The below steps are used to in solving the problem:
• First step is to assign a random values for fstar and assigned the values for variables
x1 to x7 which is 0.
• function variables are f = [2; -6;3;4;7;3;2]
• Defined upper bound and lower bound for variables from given conditions.
Lb = [2;2;3;3;0;0; -inf]
Ub = [8;8;6;6; inf;inf;inf]
%initial value
fstar= Inf; % Initialize the optimal objective function value to positive infinity
x1=0;
x2=0;
x3=0;
x4=0;
x5=0;
x6=0;
x7=0;

%%%objective function
f= [2; -6; 3; 4; 7; 3; 2];

%Lower and upper boundaries for variables

lb = [2; 2; 3; 3; 0; 0; -Inf]; % Lower bounds


ub = [8; 8; 6; 6; Inf; Inf; Inf]; % Upper bounds

%solution using linprog


for x1star=[lb(1,:),ub(1,:)]
for x2star=[lb(2,:),ub(2,:)]
for x3star=[lb(3,:),ub(3,:)]
for x4star=[lb(4,:),ub(4,:)]
for x5star=[lb(5,:),ub(5,:)]
for x6star=[lb(6,:),ub(6,:)]
for x7star=[lb(7,:),ub(7,:)]
A= [0, -1, -5, -3 , 1, -2, -3; % Coefficients matrix for inequality constraints
6, 3, 2, -1, -2, 2 ,0;
-7, -4, 3, -4, 3, -2, -1];
B = [-65; +73; -66]; % Right-hand side vector for inequality constraints
Aeq=[];
beq=[];
[X,fval]=linprog(f,A,B,Aeq,beq,lb,ub); % Solve linear programming problem
if f<fstar % Update optimal solution if the current solution is better
fstar=f;
x1=X(1);
x2=X(2);
x3=X(3);
x4=X(4);
x5=X(5);
x6=X(6);
x7=X(7);
end
end
end
end
end
end
end
end

% Display Results
disp('Solution');
disp(['x1 = ', num2str(x1)]);
disp(['x2 = ', num2str(x2)]);
disp(['x3 = ', num2str(x3)]);
disp(['x4= ', num2str(x4)]);
disp(['x5= ', num2str(x5)]);
disp(['x6= ', num2str(x6)]);
disp(['x7= ', num2str(x7)]);
disp(['optimal value ', num2str(fval)]);
Root Solver for question 1
Question 2
• The challenge's end goal is to cut down on the cross-sectional area. The design parameters
and techniques to compute them, including bending moment and axial load, are specified.
Total number of partial nodes = 3^4=81
• The smallest possible cross-sectional area requires the calculation of four separate variables in
this issue.
• The preceding first problem, limitless quantity, is comparable to this one in that both the
definition of discrete variables and the definition of f1 as an are identical.
• Next, we use a for loop on all variables to collect every possible value for them.
• At this stage, we use the appropriate equations to determine the values of the design variables
and the desired outcome.

fstar=11111111111111111111111111; % Set an initial high value for the objective function


x1 = 0;
x2 = 0;
x3 = 0;
x4 = 0;

% using solution for loop.


for x1star=[38]
for x2star=[1.9]
for x3star=[28]
for x4star=[1.1]
f= x1star*x2star+2*x3star*x4star-2*x2star*x4star; % Objective function and constraint calculations
P=140;
M=350;
s = (x1star*x3star*x4star)+(x1star*x1star*x2star)/6;
sigma_B=(1000*M)/s;
sigma_P=(10*P)/f;
g1= sigma_B+sigma_P-180;
underroot_fraction=(sigma_P/sigma_B);
numerator=(1+underroot_fraction)^2;
denominator=1+171*(underroot_fraction)^2;
g2= (x1star/x2star)-142*((numerator/denominator)^.25);
if fstar>f % Update optimal solution if the current solution is better
fstar = f;
x1=x1star;
x2=x2star;
x3=x3star;
x4=x4star;
end
end
end
end
end
% Display the results

disp('Optimal solution:');
disp(['x1 = ', num2str(x1)]);
disp(['x2 = ', num2str(x2)]);
disp(['x3 = ', num2str(x3)]);
disp(['x4= ', num2str(x4)]);
disp(['fstar ', num2str(fstar)]);
Node

You might also like