gct - optimization

Upload: safeer-mt

Post on 10-Mar-2016

32 views

Category:

Documents


0 download

DESCRIPTION

GA ACO SA

TRANSCRIPT

  • Optimization using Matlab Introductory TutorialK.RameshkumarDepartment of Mechanical EngineeringAmrita School of EngineeringCoimbatore 641 112**

  • Schematic diagram of MATLABs main features**

  • Main Matlab Window**

  • Some of the important features and special characters used in MATLAB This is the default prompt symbol in MATLAB; A semicolon at the end of a line avoids the echoing the information entered before the semicolon. . . Three periods at the end of a line indicates the continuation of the code in the next line% Any text after this symbol is considered a comment and will not be operationalMATLAB is case sensitive. Uppercase and lowercase letters are treated separately

    **

  • Some of the important features and special characters used in MATLABMATLAB assumes all variables to be arrays. As such, separate dimension statements are not needed. Scalar quantities need not be given as arrays.Variable names should start with a letter and can have a length of up to 31 characters in any combination of letters, digits, and underscores.The symbols for the basic arithmetic operations of addition, subtraction, multiplication, division, and exponentiation are +, , , /, and , respectively.MATLAB has some built-in variable names and, as such, we should avoid using those names for variables in writing a MATLAB program or m-file. Examples of built-in names: pi (for ), sin (for sine of an angle), etc.

    **

  • >> clear % removes any old variables from the workspace>> clear all% removes any old variables from the workspace>> clcClears command window & command history>> format short % outputs results in decimal form (5 decimal places of accuracy)>> format short e : (Floating point format with 5 digits)>> format long : (Scaled fixed point format with 15 digits)>> help format : prints the contents of the manual % for the command ``format'.FORMAT Default. Same as SHORT.FORMAT SHORT Scaled fixed point format with 5 digits.FORMAT LONG Scaled fixed point format with 15 digits.FORMAT SHORT E Floating point format with 5 digits.FORMAT LONG E Floating point format with 15 digits.FORMAT SHORT G Best of fixed or floating point format with 5 digits.FORMAT LONG G Best of fixed or floating point format with 15 digits.**

  • Lesson 1 : A Minimum MATLAB SessionArithmetic Operations : (interactive mode)Compute a) (25/(210))b) A=r2 where r=1/3-1 c) e163 d) Solve 3x=17 for xe) (1+3i)/(1-3i)**

  • **

  • Creating and working with Arrays of Numbers>> x=[1,2,3]x = 1 2 3>> x=[1 2 3]x = 1 2 3>> y=[2;1;5]y = 2 1 5>> z=x+y ??? Error using ==> plusMatrix dimensions must agree.

    >> y=y'y = 2 1 5>> z=x+y z = 3 3 8>> linspace(0,10,5)ans =0 2.500 5.000 7.500 10.000

    >> t=1:2:10t = 1 3 5 7 9

    **

  • Lesson 2 : Creating and working with Arrays of NumbersEx1:Equation of Straight Line : The equation of Straight Line is y=mx+c where m and c are constants. Compute y coordinates of a line with slope m=0.5 and intercept c=-2 at the following x-coordinates : x = 0, 1.5, 3, 4, 5, 7, 9, and 10.Ex2:All points with coordinates : x=rcos and y=rsin, where r is the constant, lie on a circle with radius r, i.e., they satisfy the equation x2+y2=r2. Create a column vector with the values 0,/4, /2, 3/4, and 5/4. Take r=2.**

  • Ex1>> x=[0, 1.5, 3, 4, 5, 7, 9,10]x = 0 1.50 3.00 4.00 5.00 7.00 9.00 10.00>> y=0.5*x-2y = -2.00 -1.25 -0.50 0 0.50 1.50 2.50 3.00

    Ex2>> theta =[0,pi/4, pi/2, 3*pi/4, pi, 5*pi/4]theta = 0 0.7854 1.5708 2.3562 3.1416 3.9270>> r=2r = 2>> x=r*cos(theta);y=r*sin(theta);>> x=r*cos(theta);y=r*sin(theta);Solutions**

  • Lesson 3 :Creating Simple plotsEx1Plot y=sinx, 0 x 2, taking 100 linearly spaced points in the given interval. Label the axes and put Plot created by meEx2Plot y=e0.4xsinx, 0 x 4, taking 10,50, and 100 points in the intervalEx3Plot 3D plot using plot3(x,y,z) to plot the circular helix, x(t)=sint, y(t)=cost, z(t)=t, 0 2 20**

  • Plot - Ex1>> x=linspace(0,2*pi,100);>> plot(x,sin(x))>> xlabel('x'),ylabel('sin(x)')>> title('Plot Created by RAMESH')**

  • Plot - Ex2>> x=linspace(0,4*pi,100);>> y=exp(-0.4*x).*sin(x);>> plot(x,y)

    **

  • Plot - Ex3>> t=linspace(0,20,100);>> plot3(sin(t),cos(t),t)**

  • Plot 4>>x=0:10:1000;>>y=x.^3;>>semilogx(x,y)>>semilogy(x,y)>>loglog(x,y)

    **

  • Lesson 4 : Creating & Executing script fileCreate a script file (m file) titled circle.m using the editor===%CIRCLE - A script file to draw a unit circletheta=linspace(0,2*pi,100);x=cos(theta);y=sin(theta);plot(x,y);title('Circle of unit radius')===

    The file can be executed directly from the editor or typing the file name circle in the command window

    **

  • Linear programming problem**

  • Linear programming problemVector Formf, x, b, beq, lb, and ub are vectors, and A and Aeq are matrices.**

  • Solving Linear programming problemFind x that minimizes

    f = [-5 ;-4 ;-6] A = [1 -1 1 ;3 2 4; 3 2 0]; b = [20; 42; 30]; lb = zeros(3,1);**

  • **

  • LPP Ex1**

  • Matrices and Vectors**

  • **

  • Matlab solution for Unconstrained NLP fminuncStep 1: Write an M-file ucnlp.m.function f = ucnlp(x) f = exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1); Step 2: Starting guess.x0 = [-1,1]; % Starting guess unconstrained minimization routine fminunc. **

  • **

  • Constrained Optimization problemDesign a uniform column of tubular section, with hinge joints at both ends, to carry a compressive load P = 2500 kgf for minimum cost. The column is made up of a material that has a yield stress (y ) of 500 kgf/cm2, modulus of elasticity (E) of 0.85 106 kgf/cm2, and weight density () of 0.0025 kgf/cm3. The length of the column is 250 cm. The stress induced in the column should be less than the buckling stress as well as the yield stress. The mean diameter of the column is restricted to lie between 2 and 14 cm, and columns with thicknesses outside the range 0.2 to 0.8 cm are not available in the market. The cost of the column includes material and construction costs and can be taken as 5W + 2d, where W is the weight in kilograms force and d is the mean diameter of the column in centimetres.**

  • Problem FormulationThe design variables are the mean diameter (d) and tube thickness (t ):

    The Objective function to be minimized

    **

  • Mathematical Model**

  • Optimum Solution**

  • %Step 1 : Write an M-file cnlp.m for the objective function.function f= cnlp (x)f= 9.82*x(1)*x(2)+2*x(1);%Step 2 : Write an M-file cnlp_constraints.m for the constraints.function [c, ceq] = cnlp_constraints(x)% Nonlinear inequality constraintsc = [2500/(pi*x(1)*x(2))-500;2500/(pi*x(1)*x(2))- ... (pi^2*(x(1)^2+x(2)^2))/0.5882;-x(1)+2;x(1)-14;- x(2)+0.2;x(2)-0.8];% Nonlinear equality constraintsceq = [];Matlab solution using fmincon**

  • **

  • Constrained Minimization Using GA

    Minimize the fitness function of two variables x1 and x2,

    Subject to the following nonlinear inequality constraints and bounds

    **

  • Step 1 :Create an Objective function (M-File)function y = simple_fitness(x)y = 100*(x(1)^2 - x(2))^2 + (1 - x(1))^2;

    Step 2 : Create a constraint function (M-File)function [c, ceq] = simple_constraint(x)c = [1.5 + x(1)*x(2) + x(1) - x(2);-x(1)*x(2) + 10];ceq = [];**

  • **

  • **

  • Optimization using SAfunction f = sa_dejong(x)f= 3*sin(x(1))+exp(x(2));**

  • **

  • Optimization of Cutting Parameters of Turning Process using Multi Objective Genetic Algorithm**

  • Problem DefinitionTo optimize the cutting parameters of turning operation based on Surface Roughness and Material removal Rate**

  • Factors and levels for the experiments**

    LevelSpindle Speed rpmFeed (mm)Depth of Cut (mm)111000.080.6216000.201.0323000.321.6

  • L9(3*3) ArrayTaguchi Array**

    Speed in rpmFeed in mm/revDepth of cut in mm11000.080.611000.2111000.321.616000.08116000.21.616000.320.623000.081.623000.20.623000.321

  • Factor combination & Response**

    RunSpeed in rpmFeed DocRaPredicted Ra11100 0.080.64.083.95211000.211.92.23311000.321.63.393.41416000.0810.690.78516000.21.61.441.14616000.320.63.233.06723000.081.60.590.64823000.20.61.431.39923000.3213.253.40

  • Regression analysis**

    Regression StatisticsMultiple R0.9893R Square0.9787Adjusted R Square0.9147Standard Error0.3758Observations9.0000

    ANOVAdfSSMSFSignificance FRegression612.95982.160015.29820.0626Residual20.28240.1412Total813.2422

    CoefficientsStandard Errort StatP-valueIntercept16.26312.11217.70000.0165V-0.00500.0010-4.88280.0395f-9.35976.1062-1.53280.2650d-18.88193.3220-5.68380.0296V*f-0.00660.0044-1.51790.2684f*d32.75586.47815.05640.0370V*d0.00650.00125.38390.0328

  • Objective FunctionF(x) = [F1(x), F2(x)]

    F1(x) =Ra= 16.26-0.005(V)-9.36(f)-18.88(d)-0.006(V x f) +32.76(f x d) +0.006(Vxd)

    F2(x) =Material removal rate (Mr) = 1000 x V x f x d

    Min F(x) = [F1(x), -F2(x)]

    **

  • ConstraintsVmin V vmax

    Fmin f fmax

    Dmin d dmax**

    BoundsFactorsSpindle speed rpmFeed, mm/revDepth of Cut, mmLower11000.080.6Upper23000.321.6

  • Multi Objective GA function% Multi objective GA functionfunction f=mga(x)f(1)=16.26-0.005*x(1)-9.36*x(2)-18.88*x(3)-0.006*(x(1)*x(2))+32.76*(x(2)*x(3))+0.006*(x(3)*x(1));f (2)=-1*x(1)*x(2)*x(3)*3.14*40; **

  • **

  • Thank you**

    *