MATLAB Answers

# I want to solve a problem similar to 'Solving a Mixed Integer Engineering Design Problem Using the Genetic Algorithm' as given in documentation using other solvers.

3 views (last 30 days)
Nayan Rawat on 18 Jun 2019
Edited: Nayan Rawat on 18 Jun 2019
The MATLAB files cantileverVolume.m and cantileverConstraints.m contain the fitness and constraint functions. Can i solve such problems using other solvers in Global optimization toolbox like sa, pso, patternsearch etc? Can i use optimization toolbox too, given that the variables are not continuous but discretized?
cantileverVolume.m
function V = cantileverVolume(x)
%cantileverVolume Calculate volume of a stepped cantilever
%
% V = cantileverVolume(x) calculates the volume of the stepped cantilever
% in the "Solving a Mixed Integer Engineering Design Problem Using the
% Genetic Algorithm" example.
% Copyright 2012 The MathWorks, Inc.
% Volume of cantilever beam
V = 100*(x(1)*x(2) + x(3)*x(4) + x(5)*x(6) + x(7)*x(8) + x(9)*x(10));
The cantileverConstraints.m file is given:
function [c, ceq] = cantileverConstraints(x)
%cantileverConstraints Calculate constraints in the stepped cantilever example
%
% [c, ceq] = cantileverConstraints(x) calculates the constraints on the
% stepped cantilever in the "Solving a Mixed Integer Engineering Design
% Problem Using the Genetic Algorithm" example.
% Copyright 2012-2015 The MathWorks, Inc.
% Problem parameters
P = 50000; % End load
l = 100; % Length of each step of the cantilever
E = 2e7; % Young's modulus in N/cm^2
deltaMax = 2.7; % Maximum end deflection
sigmaMax = 14000; % Maximum stress in each section of the beam
aMax = 20; % Maximum aspect ratio in each section of the beam
% Constraints on the stress in each section of the stepped cantilever
stress = [
(6*P*l)/(x(9)*x(10)^2) - sigmaMax;...
(6*P*2*l)/(x(7)*x(8)^2) - sigmaMax;...
(6*P*3*l)/(x(5)*x(6)^2) - sigmaMax;...
(6*P*4*l)/(x(3)*x(4)^2) - sigmaMax;...
(6*P*5*l)/(x(1)*x(2)^2) - sigmaMax];
% Deflection of the stepped cantilever
deflection = (P*l^3/E)*(244/(x(1)*x(2)^3) + 148/(x(3)*x(4)^3) + 76/(x(5)*x(6)^3) + ...
28/(x(7)*x(8)^3) + 4/(x(9)*x(10)^3)) - deltaMax;
% Aspect ratio constraints
aspectRatio = [
x(2) - aMax*x(1);...
x(4) - aMax*x(3);...
x(6) - aMax*x(5);...
x(8) - aMax*x(7);...
x(10) - aMax*x(9)];
% All nonlinear constraints
c = [stress;deflection;aspectRatio];
% No equality constraints
ceq = [];

#### 0 Comments

Sign in to comment.

Translated by