-
MAn.AB is a regislered lrademark ofleMalhWorks Inc.
This book is p ledon ncid paper.@
Copyrighl@22 by John Wiley & Sons New York. AII
righlsed.Published simultaneously in Cnnadn.
No pnrt of Ihis publiclllion may be reprodudstored in
atrievsystemor 1nsmittedin nny form or byanymnseleclronic
mechanicaJ pholocopyingcordingscanningor otherwise except as
permittcd under Sections 107 or 108 ofthe 1976 United Stalcs
Copyrighl Acr wirhoul either the prior writtcnprmissionof Ihe
Publisher or outhori7.3lion through paymenl of the appropriule
per-copy fcc 10 Ihe Copyrighl Clearance Cenler 222 Ro WdDrive
DnnverMA01923 (978) 7508400fnx (978) 7504744.RequIS10 Ihe Publisher
for permission should be nddressed 10 the Pemlissions Departmenl
John Wilcy & Sons Inc. 605 irdAvenue New York NY 10158-12 (212)
850-11(212)850-6008 E-Mail: [email protected].
spublicalion is designed 10 provide acculennd authorilalive
infomtalion inE10esubjecl mattercoved.It is 80ld with the
underslunding Ihal the publisher is nol engaged in
rendngprofessional services. If professionnl ndvice or othcr expert
assislance isquiredeservices of a compelent professional penashould
be soughl. Ubrary ofCongress Catalog;lIg;n P"bl;catiotl Data:
VenkoluromnP. Applied oplimiZlllion with MATLAB~ Programming I
P. Venkalarmlln.
p. com. A Wiley-Intersciencc publicnlion." ISBN 0-471
958.5(c1oth : alk. pnper) 1. MnlhemalicaJ optimization--Dolll
procing2.MATLAB. J. Title.
QA402.5.V42 2001 519.3-dc21
Prinled in Ihe Uniled Slales of Americn.
10987654321
2001026938
~.4r;r:T--
T 0 coexistence of peace and harmony between the different
melodies of people everywhere
6
-
CONTENTS
PREFACE
1 Introductlon
1.1 Optimization Fundamentals I 2 1.1.1 Elements of Problem
Formulation I 4 1.1.2 Mathematical Modeling I 10 1.1.3 Nature of
Solution I 16 1.1.4 Characteristics of the Search Procedure I
20
1.2 Introduction to MA11..As I 25 1.2.1 Why MATLAB? I 25 1.2.2
MATLAB Installation Issues I 26 1.2.3 Using MATLAB the First Time I
27 1.2.4 Using the Editor / 33 1.2.5 Creating a Code Snippet / 37
1.2.6 Creating a Program I 40
Problems I 44
xiii
1
2 Graphlcal Optlmizatlon 45
2.1 blemDefinition I 45 2.1.1 Example 2.1 I 46 2.1.2 Format for
lhe Graphical Display I 47
2.2 Graphical Solution I 48 2.2.1 MATLAB High-Level Graphics
Functions I 48 2.2.2 Example 2.I-Graphical Solution I 50 2.2.3
Displaying the Graphics I 53 2.2.4 Customizing the Figure I 54
2.3 Additional Examples I 56 vll
-
vlll CONTENTS
2.3.1 Example 2.2 I 56 2.3.2 Example 2.3 I 64 2.3.3 Example 2.4
I 73
2.4 Additional MA11..AB Graphics I 79 2.4.1 Handle Graphics I 80
2.4.2 Graphical User Interface I 81 2.4.3 GUI Code I 84
References I 91
Problems I 92
3 Llnear Programmlng
3.1 Problem Definition I 94 3.1.1 Standard Format / 94
3.1.2 Modeling Issues / 98
3.2 Graphical Solution / 107
3.2.1 Example 3.1 / 110
3.2.2 Characteristics of the Solution / II1
3.2.3 Different Solution Types I 114 3.3 Numerical Solution-the
Simplex Method I 115
3.3.1 Features of the Simplex Method / 115
3.3.2 Application of Simplex Method / 117 3.3.3 Solution Using
MA11..AB / 120 3.3.4 Solution Using MATLAB'S Optimization Toolbox I
123
3.4 Additional Examples / 124
3.4.1 Example 3.2-Transportation Problem / 124 3.4.2 Example
3.3-Equality Constraints and Unrescted
Variables / 130
3.4.3 Example 3.4-A Four-Variable Problem / 134 3.5 Additional
Topics in Linear Programming / 138
3.5.1 Primal and Dual Problem / 138
3.5.2 Sensitivity Analysis / 148
Refernces/ 151
Problems / 152
4 Nonlinear Programming
4.1 Problem Definition I 155
93
154
CONTENTS Ix
4.1.1 Problem Formulation-Example 4.1 / 155
4.1.2 Discussion of Consaints/ 157
4.2 Mathematical Concepts / 159
4.2.1 Symbolic Computation Using MATLAB / 159
4.2.2 Ba~ic Mathematical Concepts I 162 4.2.3 Taylor's
Theorem/Series / 169
4.3 Graphica1 Solutions / 171 4.3.1 Unconstrained Problem /
171
4.3.2 Equality Constrained Problem / 172 4.3.3 Inequality
Constrained Problem / 173 4.3.4 Equality and Inequality Constraints
/ 174
4.4 Analytica1 Conditions / 175 4.4.1 Unconstrained Problem /
176 4.4.2 Equality Cons inedProblem I 179 4.4.3 Inequality
Constrained Optimization I 186 4.4.4 General Optimization Problem /
191
4.5 Exnples/ 194
4.5.1 Example4.2/ 194
4.5.2 Example 4.3 / 196
References / 200
Problems / 201
5 Numerical Technlques-The One-Dlmenslonal Problem 5.1 Problem
Definition I 204
5.1.1 Constrained One-Dimensional Problem / 204
5.2 Solution to the Problem / 205
5.2.1 Graphical Solution / 205 5.2.2 Newton-Raphson Technique /
206
5.2.3 Bisection Technique I 209 5.2.4 Polynomial Approximation /
211 5.2.5 Golden Section Method I 214
5.3 Importance of the One-Dimensional Problem / 217
5.4 Additional Examples I 219
203
5.4.1 ample5.2-Il1ustionof Geneml Golden Section Method / 219
5.4.2 Example 5.3 Two-PointBoundary Value Problem I 220 5.4.3
Example 5.4-Root Finding with Golden Section I 223
-
X CONTENTS
References I 225
Problems I 225
6 Numerlcal Technlques for Unconstralned Optlmlzatlon
6.1 Problem Definition I 227 6.1.1 Example 6.1 I 228 6.1.2
Necessary and Sufficient Conditions I 228 6.1.3 Elements of a
Numerica1 Technique I 229
6.2 Numerical Techniques-Nongradient Methods I 230 6.2.1 Random
Wa1k I 230 6.2.2 Pattem Search / 234 6.2.3 PoweJ1's Method I
238
6.3 Numerical Thniques-Gradient-BasedMethods I 241 '6.3.1
Steepest Descent Method I 241 6.3.2 Conjugate Gradient
(F1etcher-Reeves) Method I 244 6.3.3 Davidon-FJetcher-PowelI Method
I 246 6.3.4 Broydon-Fletcher-GoldfartShannoMethod I 249
6.4 Numerical Techniques-Second Order I 251 6.5 Additional
Examples I 253
6.5.1 Example 6.2-Rosenbrock Problem / 253
227
6.5.2 Example 6.3-Three-Dimensional Aow nraRo ngDiskI 255 6.5.3
ExampJe 6.4-Fitting Bezier Parametric Curvcs I 258
References I 262
Problems I 263
7 Numerlcal Techniques for Constralned Optlmlzatlon 265
7.1 Problem Definition I 266 7.1.1 Problem Formulation-Example
7.1 I 266 7.1.2 Necessary Conditions / 267 7.1.3 Elements of a
Numerical Technique I 269
7.2 Indirect Methods for Constrained Optimization I 270 7.2.1
Exterior Penalty Function (EPF) MeodI 271 7.2.2 Augmented Lagrange
Multiplier (ALM) Method I 276
7.3 Direct Methods for ConsainedOptimization I 281 7.3.1
Sequentia1 Linear Programming (SLP) I 284 7.3.2 Sequential
Quadratic Programming (SQP) I 289
CONTENTS xl
7.3.3 Genera1ized Reduced Gradient (GRG) Method I 297 7.3.4
SuentialGradient Restoration AJgorithm (SGRA) I 302
7.4 Additiona1 ExampJes I 307 7.4.1 ExampJe 7.2-FJagpoJe Problem
I 307 7.4.2 ExampJe 7.3-Beam Design I 310 7.4.3 ExampJe 7.4
Optima1Control I 313
References I 316
Problems I 316
8 Dlscrete Optlmlzation
8.1 Concepts in Discrete Programming / 320 8.1.1 Problem
Relaxation I 321 8.1.2 Discrete Optimal Solution I 322
8.2 Discrete Optimization Techniques I 324 8.2.1 Exhaustive
Enumeration I 326 8.2.2 Branch and Bound I 329 8.2.3 Dynamic
Programming / 336
8.3 Additional Examples I 341 8.3.1 Exnmple 8.4--1 Beum Design I
341 8.3.2 Zero-One Integer Programming I 343
References I 348
Problems I 348
9 Global Optlmlzation
9.1 Problem Definition I 351 9.1.1 Global Minimum / 351 9.1.2
Nature of the Solution I 354 9.1.3 Elements of a Numerica1
Technique I 356
9.2 Numerical Thniqusand Additional Examples I 357 9.2.1
Simulated Annealing (SA) I 358 9.2.2 Genetic Algorithm (GA) I
366
References I 377 Problems I 378
10 Optlmization Toolbox from MATlAB
10.1 The Optimization Toolbox I 380
318
350
379
-
xll CONTENTS
10.1.1 Programs I 380 10.1.2 Using Programs I 382 10.1.3 Setting
Optimization Parameters I 384
10.2 Examples I 385 10.2.1 Linear Programming I 385 10.2.2
Quadratic Programming I 386 10.2.3 Unconstrained Optimization I 388
10.2.4 Constrained Optimization I 389
Reference I 391
Index 393
PREFACE
lesu~ject of optimization is receiving serious
attentionomengineers scientists managers and most everybody else.
This is driven by competion quality assurance cost of production
and finally the success of the business entee.lgnoringepractice of
optimization is not an option during current times. Optimization is
practiced through softwar programsand requires significant
computer resources. The techniques of optimization have not
changed significantly in centyears but tlle areas of applications
have mushroomed at a significant rate. Successfully embedding the
use of optimization in professional practice requires at least
three Pquisites.beyinclude mathematical modeling of the design
problem knowledge of computer programming and knowledge of
optimization techniques. Many special-purpose optimization software
packages relax requiredknowledge of programming are available
today. To use them efficiently the remaining two areas still have
to be addressed. lereare several excellent books on the subject of
optimization a few of them
released recently. Most of them covrthe subject in depth. which
is necessary because thmathematicalmodels are nonlinear and require
special techniqusthat are usually notpaofany core curriculum. All
ofebooks assumeereader is familiar wilh a programming
languageaditionallyFORTRAN and recently C. Another assumplion
hquentlymade is theoptimizationchniqueswi1l be implemented in a
mainframe computing environmenl. Such a combination is
exemelydifficu1t for the self-Iearner even with enormous
motivation. An explosion of inexpensive desktop computing resources
aids engineering design
practi today.Paralleling this development iseavailability of
extensivesouon the Internet both for learning and deployment. This
is joined by the availability of sofsystemsthat provide
opportunityfor handling mathematics graphics. and programming in a
consistent manner. These software systems are significant1y easy to
master compar tothe higher-level programming languages of the
pviousyeS.lisbook primarily seeks to harness thisiangulationof
srvicesto provide a practical approach to the study of design
optimization.lebook uses MATI.AB@ to i11ustrate and implement the
various techniques of optimization. MATLAB is a product from
MathWorks. Inc. This book attempts 10 accomplish two important obj
tives.The fir
-
xlv PREFACE
of symbolic. numerical. and graphical fl
turesofMATLABltintegratesispowerful combination duringnslationof
many algorithms into app1ied numerical techniques for design
optimization. There is a constant enhancement of the programming
skills throughout thbook.The second 0ectiveis thprimarytask of
book-tocommunicate and demonstrate various lIumerical techniques
that are
currenlusedin tlte area oloptimal des.AH of thc numerical
techniquesMEsupported by MMLAB code available
computer files. These files are available on a companion web
site www.wilev.comlvenkat.ltis necessary to visit the web site to
download thc files to fo l l o w a l l of t h e E X tl I n p i es
-Th e b oo k w i l l b e e ntiallyincomplet.ewitho0utthcsc files.
At the web site you will also find uscful links 10 other resources
a web course on MATLAB programmingand updated information about
Applied Optintimuon with MATl.AB@ Programming. The decision to
locate the files on a web site pmvidEs an avenue to shadow the
dynamic changes in MATLAs sof1ware itsclf which is bcing
transformed in a major way almost every ycar.lt provides a
mechanism 10 correct bugs iecode in a timely manner. It estabishes
an opportunity to improvecodethrough reader suggcstions and
provides a way foreauthor 10 keep thc rcader engaged with new
dcvclopments. It docut down the sizc of the book enormously by
locating all of the pag ofcodeoutside the book. An unusual feature
of the book iscinclusion of discrete optimization and global
optimization. Tradilional continuous design optimization
techniques do take up a significant portion of the book. Continuous
problems generally allow the algorithms to be mathematically
developed in a convincing manncr andeideas could becore of original
a1gorithms dcvc10pcd by the readers to address their own special
necds. Every chaptcr includes additional nontrivial cxamp1esatoftcn
prescnt a novel use or extcnsion of thc optimization techniques in
the chapter. The mathcmatical algorithms and cxamples ar
accompaniedby MA' ABcode available at the companion web
sue-Thenumerical techniques usually include strong graphical
support to il1ustratecopcration of thc techniques. Discrete
andglobal optimization techniques are basedon
verydifferentalgorithms
and.chof thcm can easily justify full-fledged independent
courscs detcdexclusively 10 thcir S1udy. In a comprchensivc book
such
PREFACE XV
classroom setting withou1 computational cxperience is also
feasib1e. Iniscase the a1gorithms can be presented and the
nurnerical results illustrated. The senior/gradua1e s1udents in
various discipines. especially engincering are the targc1 audience.
Optimization techniqucs are an importanl 1001 to solve dcsign
problems in all professional areas of study. Many illustrations
areomthe area of mechanical engineering
reflectingexperienceofeauor.Independent learnel's particuIarly
professionals who need to understand the subject
of optimization should also find the book very useful. A reader
who has access to MATLAB software c us thebook to its best
advantage. The book is largely self-contained and develops all
ncccssary mathematical concepts when ncedcd. Abstract mathematical
idcas of optimi tion introduccdgraphically and through iIlustrative
examples in thc book. In many instances the operation of thc
numcrical technique isatcdto show how the design is changing with
iterations. This has been possible because MATLAB graphics are rich
in fcatures and simple to incooratc.making Ulcm cffcctive for
convcyingeidcas. It is for this reasonereader is cxposed to
graphical programming early on incIuding a chapter on graphical
optimization. To balance thc development of programming skills and
thpresentationof optimization concepts programming issues are
incrementally explored and implemented. Investment of time in
dvelopingprogramming skills isemost effective way to imbibe them.
Thc author is nOl aware of shortcuts. Studcnts arc expected to
program independently. make mistakes debug errors. and incorporate
improvements as ptof their learning experience delivered
throughisbook. The book proceeds at a brisk pace to provide
experiencc in MATLA8 programming
and communicate ideas in optimization in a reasonable number of
pages. This could not be possible without taking advantage of Ihe
accompanying web site 10 locate much of the code for algorithms and
examples. Merely running the code will n01 significantly ecethe
reader's programming skills. It is important for the student to
understand the code also. To sistinisprocess the code carries
Iiberal comments often corresponding to the algorithm that is being
implemcnted. The auorexpects ereader to have readecomments. The
accompanying code allows the instructor to assign both programming
assignments as well as so
-
xvl PREFACE
approaches the instructor can choose to include only a subset of
continuous optimization algorithms to allow the inclusion
ofesepopular techniques. Ifestudent has access to the Optimization
Toolbox from MATlABenit can be integrated intoecourse for handling
the final design project. The last chapter provides an overview on
the use of the toolbox. This book started out using MATI.AB Version
5. About halfway through the book
etransition to MATlAB Version 5.3 was complete. At the
completion of the m uscriptMATLAB Version 6 wshipping for some
time. As of this tirne Version 6.1 is available. Most institutional
MATlAB licenses are usually based on subscription sotheywill
havelatestversion ofesoftware. In a sense andisis true of all books
that depend on particular software systems the book rnay appear out
of date with respect toesoftware. This is not really so. While the
usage ofMATLAB functions rnay change between versions there should
be suitable wamings and instruction about edifferent
usageAnimportant insurance is built into the book particularly to
handle such changes if they arise. Sprinkled throughout the book is
the habit ofeusingeonline help. In most instancesiswas primarily
done to expose the reader to alternative use of the same command.
Another significant change the manuscript had to endure waseloss of
access to a UNIX version because of thuniversity'schange to
distributed computing on PC clusters. The author's experience
wieearly chapters suggs18that this should not mat1er. Except for
external files and resources useof MATlAB as illustrated in the
book is indifferent to the various operating sy(WindowsMac UNIX or
Linux). The topics chosen for inclusion and the simplicity of
presentation ofetopics are
directly related to the experience of teaching the course on
optimization at the senior/graduate level ineDpartmentof Mechanical
Engineering for over ten years. Experience provedatcomprehension
irnproved with simple iIIustrations however complicated the
mathematical ideas. On the other hand straighorwardmathernatical
expressions elicited no interest or understanding. The emphasis on
application was important to keep the students' attention. In this
connection the author would like to 1kall his studen18 for pushing
hirn for simple explanations for providing positive interaction and
for their contribution of original and useful ideas in the
discuss
PREFACE xvii
???
????
The book was made possible through support from John Wiley
dSonsInc.dMathWorks Inc. Sincere thanks are owed to Bob Argentieri
senior editor at Jobn Wiley for accepting the proposaland who all
along displayed a lot of patiencein getting the book moving
forward.Same is due to Bob Hilbed-associate managing editor at John
Wiley for his impssivework at c1eaning up the manuscript. Brian
Snapp New Media editor at John Wiley created companionweb site
(www.wiley.comlvenkat) and w alsobe rnaintaining it. Naomi
FemandesomMathWorks Inc. saw to itat1 had the latest version of
MATLAB as soon as it was available. My regard for Dr. Angelo Miele
Professor Emeritus at Rice University is more than can be expressed
in these Iines. It was he who introduced me to 1hsubjeclof
optimization and demonstrated the effectiveness of simple
presenution-I will always regard him as a great teacher. Of course
my family deserves special rnention for putting up with all the Not
now"Later"How about tornorrow?" din2debuggingecode. Spialksare to A
ana dVinayak rny offspring titheir patience understanding and
encouragement. The auorapologizes for any shortcornings on the
presentation and welcomes comments criticisms and suggestions for
improvement at all times.
P. VENKATARAMhN RochesteNewYork
-
1-a.. ? ?
??
? ?
? ? ?
??????????
INTRODUCTION
Optimization has become a necessary part of design activity in
all major disciplines. These disciplines are not restricted to
engineering. The motivation to produce economically relevant
products or services with embedded quality is the principal reason
forisinclusion. Improved production and design tools wiasynergistic
thrust through inexpensive computational resources have aided the
consideration of optimization methods in new developments
particularly engineering products. Even in the absencc of a
tangible product optimization ideas provide the ability to define
and explore problems while focusing on solutionsatsubscribe to some
measure of usefulness. Generally the use of the word optimization
implisthc best result under thcircumstances.This includes the
particular set of constraints on the development rcsources current
knowledge market conditions and so on. Every one of us has probably
used thc term at some time to describeeprimary quality of our work
or endeavor. It is probablyemosl used or abused lerm in advertising
and presentations. Neverthclesscability to make the best choice is
a perpelual desire among us all. Optimization is frequently
associated with design be it a product service or
strategy. Aerospace design was amongearliestdisciplines to
embrace optimization in a significant way driven by a natura1 need
to lower the tremendous cost associated with carrying
unnecessyweight in aerospace vehicles. Minimum mass structures arl
norm.Optimization forms part of the psyche of every aerospace
designer. Saving on fuel through trjectorydesign was another
problem that suggested itself. Very soon enti engineeringcommunity
could recognizecneed to define solutions based on merit.
Recognizing the desire for optimization and actua1ly implementing
we twodifferent issues.
-
2 INTRODUCTION
Until recently. for much of the time. optimization was usually
attempted only in those situations where there were significant
penalties for generic designs. The application of optimi
tiondemanded large computational resources. In the nascent years of
digital computation these were available only to large national
laboratories and research programs. These resources were necessary
to handle thnonlinearproblemsat associatedwith engineering
optimi.tion.As a result of these constraints most of the everyday
products were designed without regard to optimization. This
includes everything you soundyou or use in your daily life. It is
inconceivableatthe new generation of replacement products. likc the
car. the house. the desk. orepencil. redesigned and manufactured
today arc not designed optimally in one sense or anothcr. Today.
you would defmitIyexplore procedures to optimize your
inveslentsby
tailoring your portfolio. You would optimize your business
travel time by appropriaIychoosing your dcstinations. You can
optimize your commuting timbychoosing your time and route. You can
optimize your necessary expenditure for Iiving by choosing your day
and store for shopping. You can optimizc the useful time you
connecttoIntemetby detcrmining your time of connection. You can buy
software willoptimize your conncction to thc lntemct. You can buy
books or read articles tcllyou how to perform these various
optimizations. The above activitics primarily relatc to :;crvIces
or strategy. It is now apparcntatevery activity except
aSeticprovides the scope for optimization.lisjustifies looking
atestudy of ootimizonas a toolcanbe applied 10 a variety of
disciplines. If so the myriad
ofoptimizationproblemnsso11IThisiseemphasisofthebook. The
partnership between dsignand optimization activity is often found
in
engineering. This book recognizes that connection and many of
thc problems used for illustrations and practice are from
enginringprimariIy mechanical civil and aerospace design.
Ncvertheless the study of optimization. particularly applied
optimization.is not m exclusive pmperty ofmy sptcinc discipurle.It
involves the dECOVEryanddesignof utionsthrough appropriate
techniques ociatedwith the formulation of the problem in a sp
ificmanner. This can be done for example in economics chemistry and
business man
1.1 OPTIMIZATION FUNDAMENTALS
Optimization can be applied to all disciplincs. Qualitatively
this assertion implies multiple decision choices; implicitly
recognizing the ncessityof choosing among a1tematives. This books
deals with optirnization in a quantitative way. This means that an
outcome of applying optimization toeproblem design. or service must
yield numberatwill define the solution. or in other words numbers
or valueswillcharacterize the particular design or service.
Quantitative dcscription oflutionrequires a quantitative
description of the problem itself. This description is called a
;:.~ ". "
1.1 OPTIMIZATION FUNDAMENTALS 3
mathematical model.bedi.icharactcrization. dits circumstances
must be expressed mathematically. Consider the design activity in
the following cases:
New consumcr research indicatthat people like 10 drink about 0.5
litcr of soda pop al a time during the summer months. The
fabrication COSI of the redesigned soda can is proportional
tosurfacearea. and can be estimatcd at $1.00 pcr square meter of
the materiaI used. A circular cross section is the most plausible
given current tooling available for manufacture. For aesthetic
reasonseheight must be at least twice the diametcr. Studies
indicateatholding comfort requires a diameter between 6 and 9
cm.
A cantilever beam nceds to be dcsigndto carry a point load F at
the cnd of a beam of length L. The cross section of the beam wiII
be in the shupe of thltterI(edas I-bm).The beam should meet
prescribed failure criteria. ereis also a limit on idefItion.A beam
of minimum mass is requir tobe designed.
MyPC Company has decidcd to invcst $12 million in acquiring
several nWComponenl Placemnl Machines to manufacture differcnt
kinds of mothcrboards for a ncw gcncration of personal compulers.
Three models of thcsc machines are under consideration. Total
numbcr of operators available is 100 becausc of the local labor
market. A fIoor spacc constraint needs 10 bc satisfied because of
the diffcrent dimcnsions of thcse machines. Additional information
rclating to each of the machines is given in Table 1.1. The company
wishes to determine how many of each kind is appropriate 10
maximize the number of boards manufactured per day.
The above list rcpr entsthree problemsatwiII be used 10 definc
formal elements of an optimization problem. Each
problemquiresinformation from the specific arca or discipline to
which it refers. To rccognize or design these problems
assumesatdesigncris conversant wieparticular subj
tmatter.leproblems are kept simple to focus on optimization issucs.
Problems of such variely are important today. Recent advertisements
in general consumer magazines i1IustrateatAlcoa (an aluminum m
ufaclurer)is quithappyto have rcducedLhc weight of the standard
soda pop can by over 30% in recenl years. A similar c1aim by the
plastics industry with respect to the standard milk jug (gaIlon) is
al50 evident in these magazines although iniscase the number is
409.Roof coUapses incNortheast due 10 excessive snow
Table 1.1 Component Placement Machir
Machine Operablc Model BoardTypes BoardslHour Opemtors/Shift
HoursIDay CostIMachine
A 10 55 18 400000 B 20 50 2 18 600000 C 18 50 2 21 700000
-
4 INTRODUCTION
during the 1998-1999 winter will have structura1 designers and
homebuilders exploring secondproblem. Thvibrantstock market in
these times has made ba1ancing the investment portfolio more
challenging. Thc third case may suggest a mathematica1 model
appropriate for such decision making.
1.1.1 Elements of Problem Formulatlon
In this section we will in duceeforma1 elements of thc
optimization problem. In this book the tcrm product a1sofersto a
servicora strategy. It should be understoodatopzationpresupposes
the knowlcdge ofedesign rules for the sp ificproblem primarily the
ability to describe the design in mathematica1 terms. These
termscJudedesign variables design parameters and design functions.
Traditiona1 design practiatis design without regard to optimization
incJudes a11 of these elementsugheywere not formally recognized as
such. This also justifieseprerequisi thatyou must be capable of
dcsigning the 0tif you are planning to applyetechniqucs of optimi
tion.It is al80 a good idea 10 recognizc that optimization is a
procedurc for scarching 1he best design among candidatscach of
which can produce an acceptable product. The oced for thc objec1 or
product is not questioned here. but this may be due to a decision
based 00 optimization applied in another disciplinc.
Deslgn Varlables: Design variables are entities that identify a
particular design. In esearch foroptimaldesigneseentities will
change over a prcscribed range. The values of a complete set of
these variables charactcrize a specific design. Thnumber and type
of cntities bclonging to this set are vcry important in identifying
and setting upequ titativedesign problem. It is essentialischoice
captueessence of objectbeing desied datesamc time provide a
quantitative characterization of the design problem. In applicd
mathematical terminology. design variables serve as the unknowns of
the problem being solvcd. Borrowing an ana10gy from the area of
system dynami andcontrol theoryeyare equiva1ent to defining the
state of the systcm iniscase thc statc of design. Typically design
variables Can be associatcd with describingobject'ssize such as its
length and height. In other cesthey may represen1 the number of
items. The choice of design variables is the responsibility
ofedesigner guidcd by intuition expeseand knowledge.le isa
fundamenta1 requirement to be mct byisset of design variables
namelyeymust be Iinearly independent. This meansa1you cannot
cstablish thvalueof onc ofedesign variables fromevalues
oferemaining variables through basic arithmetic (scaling or
addition) operations. For example in a design having a rcctangular
cross section you cannot haveevariables reprentingelcngwidth and
area. If the first two arprescribedethird is automatica1ly
established. In complex designs these relationships may not be very
apparent. Nevertheless the choi ofthe set of design variables must
meet criterionof linear independence for applying the techniques of
optimization. From a practicnl pcrspcc1ivc thc property of Iinear
independence identifies a minimum set of variables that cun
complctely describe the
r::.-: l
'"
1.1 OPTIMIZATION FUNDAMENTALS 5
design. This is significant because the effort in obtnining the
solution varies as an integer power of the number of variables and
this power is 1ypica11y greateran2. Mtingthe requirement ensures
reduced difficulty in mathematically exploring thc solution. leset
of design variables is identified as the design vector.1Isv torwill
be
consider acolumn vector in this book. In fac1 a11 vectors are
column vectorsEtext. The length ofisvector which is n is the number
of design varilesioEproblem. The design variables can cxpress
different dimensional qu titiesinproblem but in the malhematical
model they are distinguished bycharac1erx. AlI of the techniques of
optimization in this book nre bascd oneabstract mathematical
model.lesubscript on x for cxamplc X3rcpresentsthe third design
variable which may be the height of an objec1 inechucterizationof
the product. This abstract model is nessaryfor mathematical
convenience. This book will refer toedesign variables in one
offollowingways:
(1) [-refcingto the vcc10r 01' dsignvariablcs (2) X or
x-referring to thc vcctor again omilling 1hc square brackets for
convcnicncc if appropriate
(3) [xj x2'...XIl]T_indicatingthc vcclor lhrough its elements.
Noleesuperscript transposition symbol to identify it as a colunm
vector.
(4) X;. i = 1 2. . . . n-referring to all of the elements of the
design vctor.
Thc above notationa1 convenience is extcndcd to all vcctors in
the book.
Deslgn Parameters: Inisbookeseidentify constan1will not
changedierentdesigns are compared. Many 1exts use termdesign
parameters 10 prescntdcsignvariables we defined earlier and do not
formally recognize design parameters as defincd hc.The principnl
reason is that parameters have no role 10 play
detenningoptima1design. They are significant in the discussion of
modeling issues. Examples of parameters include matcria1
propcyapplied loads. and choicc of shape. The paramctcrs in the
abstract mathematical model are repsentcdin a similar form as the
design vec1or excep1 twe use the charactcr p. Therefore. [P] P
[P"P2'...Pq1 repsenteparameters of the problem.
Noteelengoftheparnervector is q. Except incdiscussion of
modelingeparneterswill not be explicitly rredto as they are
primarily predetrmincdconstants indesign.
Des'nFunctlons: Design functions define meaningful information
about the design. They are evaluated using the design variables and
design parameters discussed earlier. They establish the
mathematical model of the design problem. These functions can
represent design objective(s) andlor constraillts. As iname implies
design 0ectivedrives the search for the optimal design. The
satisfaction of the trailltsestablishes the validity of the design.
If not explicit1y statededesigner is responsiblc for idntifyingthc
objectivc and constraints. Minimize the mass of the
-
6 INTRODUCTION
structure will translate to objectiveU1ction.The sin the
material must be less than the yieId strength wi1l translate to a
constraintfunction. In many problems it is possible for thc same
function to switch roles to provide diffcrcnt design scenarios.
ObJectlve Function Thetraditional design optimization problem is
dcfindusing a single objective function.leformat of this statemcnt
is usually to minimizc or maximize some quantity iscalculated using
somc dcsign function. This function must depend explicitly or
implicitly on the design variables. In the literaturcisproblcm is
cxpssedexc1usively without loss of generaIity as a minimum problem.
A maximum problem can brccastas a minimization problcm using the
ncgativc orreciprocalof thc function used for the objectivc
function. ln the first example in ducedearliercoectiveis to
minimize cost.lereforedesi functionrepresgcost wilI be the
objective function. Inesecond seeobjective is to minimize mass. In
the third case the objective is to maximizc machine
utilization.lear ofsingle objective desi isconsidered mature today.
No new solution techniques for classical problcms havbecnadvanced
for somc time now. Today. much of the work in applied optimitionis
dirccted at expanding applications to practical problems. ln many
cases. this has involved crcative use of the solution techniques.
In abstractmathematical model. the objective function is
reprosented by the symbolf To indicate its dependence on the design
variables. it is fquentlycxpressed f(x"x2.. . . xn). A more
conciscprcsentationis j{X). Single objective problcms have only one
function dcnoted by f It is a scaIar (not a V tor).Notcatalthough
the objcctive function depends on P (parameter vector). it is not
explicitly inc1uded in the format. Multiobjective and
multidisciplinary dsignsarc important developments today.
Multiobjtive design or multiple objecti ve design. refersusing
sevcraI dierentdesign functions toeshfor opnaldign. GeneraIlyeyare
expecdbeconflicting 0cctives.They could also beopcrating
objectives.lecurrent approach toesolution of these problems
involves standard optimization procedapplicdto a single
(onstructedobjective optimization problcm based on the different
multiple objectives. A poparapproach is to use a suitably
weighdlinrcombination ofmultiplc objectives. A practicallimitation
wiisapproach is.echoi ofweights usin the model. This approach has
not been cmbraced widely. An altemative approach of recognizing a
prcnectiveand solving a singlc objectivc problem with additional
constraints based onningovenctionscan usually geneaccep lesolution.
In multiobjective problen
???
? ?
??
1.1 OPTIMIZATION FUNDAMENTALS 7
Constraint Functlons: As design functions these will be
influenced by the design variables. The format of these functions
requires them to be compared to some numerically limiting valueatis
established by design requirement or the designer. This value
remains constant during thc optimization of the problcm. A
wcl1-describcd dcsign problem is expected to inc1ude scveral such
functions. which can be represented as a vcctor. The comparison is
usual1y set up using the threc standard onaloperators: = S
and.Consider our first example. LetfimJ(X) represent
efunctioncalculatesthe volume of the new soda can we are
designing.leconstrnton the dsigncan bc expresscd as
IIJ(X)= 500 cmJ
In tlIe second example.letm2(X) bthefunction that calculates the
deflection of the beam under the applied load. The constraint can
be statcd as
ft11l2(X) :S; I mm
Thccons intfunctions can be c1assified as eqllality constraints
[likefunl(X) aboveJ or inequality consnts[likefun2(X)]. Problems
without constraints are tcrmcd unconstrained problems. If
constraints are
present then meeting them is more pmountanoptimizalion.
Constraint satisfaction is necessary beforc the dcsign established
by currcntvalue of the desi variablesis considered valid and
acceptable. If constraints are not ssfiedthen there is no solution.
A feasible design is one in which all of the constraints are
satisfied. An optimal solution is oneathas met the design
objective. An optimal dcsign must be fcasiblc. The design spacc
cncloscd by thc constraints is called the feasible domain. Dcsign
space is described a few paragraphs bclow.
Equallty Constralnts: Equality constraints are mathematically
neat and easy to handlc. NumericallyeyJ1uiremore effort to satisfy.
They are also more restrictive on tlIe designthey limit the region
from which the solution can be obtained. The symbol representing
equality constraints in the abstract model is h. There may be more
than one equality constraint in the design problcm. A vector
representation forualityconstraints is introduced through the
following representation. [8] [hl h2 . . . . h]. and hk: k = 12 . .
. .1 are ways of identifyingeequality constraints.ledependence on
the design variables X is omitted for convcnience. Notcatthe length
of the vector is 1. An importantonfor distinguishing the equality
and inequality constraints isatthey arc mnnipulated differently in
the senrch for the optimal solution. The number n of design
variables incproblcm must be greatcr thenumber of equality
constraints 1 for optimization to take place. lf n is cqual to 1.
then problemwill be solved without reference to the objective. ln
mathematical terms the number of equations matchesenumber of
unknowns. If n is less than 1 then you have an overdetermined scl
of relations which could result in an inconsistent problcm
definition. The sct of cquality constraints must be linearly
indcpendent. Broadly this
-
8 INTAODUCTION
implies youcannot obtain one of the consaintsfrom elementary
arithmetic operations on the rcmaining constraints. This serves 10
ensure that the mathematical search for solution will not fail.
These tcchniques are based on methods from Iincar algebra. In the
standard format for optimization problems theua1ityconsaintsare
written with a 0 on the right-hand side. This meanseequality
constraint in thc first example will be expssedas
hl(X):funl(X) -500 = 0
In practica1 problems equality constraints are
rarIyencountcred.
Inequallty Constraints: Inua1ityconsaintsapp rmore naturally in
problcm formulation. Inequality constraints also provide more
flexibility in dcsign selection. The symbol represcnting inequality
cons'aintsin the abstract model is 8. There may be more
oncinua1ityconstraint in the design problem. The vector
reprsentationfor inequality constraints is similar to what we
havseenbefore. Thus [G) [8182 . . .811/]and:j = 1 2 . . . m arc
ways of identifying Ihe inequality consaints.m reprentsenumber of
inequa1ity constraints. AIl design functions explicitly or
implicitly depend on the design (or independent) variable X. 8 is
used to descriho bo lossthun or cqual 10)dgrealcr 01"equlll 10
()constralnts. Strictly greater(>)and strictly Icss th(
-
10 INTROOUCT10N
xlsxjSx i=12... n Exploiting vector notation the mathematical
model is
Minimize j(X) [X].
Subject to: [h(X)]1 = 0
(X)]tnS 0
X10wSX S Xup
(1.8)
(1.9)
(1.10)
( 1.11)
(1.12)
The above mathematical model expresses followingstandard format
of the optimizonproblem expressed in naturallanguage:
Minimize the objective functionj subject to 1 equaity
constraints m incquality constraints withen design variables Iying
between prcribed lower and upper limits.
letechniqucs inisbook will apply to thc problem describcd
incabovc format. To solve any specific design problem it is
requircd 10 refunnulatc the problcm in the above manner so
methodscan be applied directly. Also in this book the techniques
are developed progressively by considering the standard model
widucedelements. For example thunconstrainedproblem wil be
explodfirst. The equality cons intsa considerednext followed by the
inequality constraints. dfinally the complete model. This
represents a natural progression as prior knowledge is used to
develop additional conditions needto be satisfied by the solution
in einstances.
1.1.2 Mathematlcal Modellng
In this sectionethree design problems i'Oducedearlier will
beanslatedtoestandard format. The mathematical mode1 will first be
identified. The second problem requires information from a course
in mechanics and materials. This should be within .epurview of most
engineering students.
Example 1.1 New consumer research indicatesatpeople like to
drink about 0.5 liter of soda pop at a time during the summer
months. The fabrication cost of the redesigned soda can is
proportional 10 the surface area and can be estimaled al $1.00 per
square meter of lhe matrialused. A circular cross section is the
most plausible given current looling available for manufaclure. For
aesthetic reasons tl1e height must be at least twice tl1e diameter.
Studies indicateatholding comfort requires a diameter between 6 and
9 cm. Figurc 1.1 shows a sketch of tl1e can. In most product
designs particularly in
engineringthe model is easier to develop using a figure. The
diameter d and the height h are sufficient to dcscribe tl1e soda
can. What about the tl1ickness t ofe
~
p J :
-
12 INTRODUCTION ????? 1.1 OPTIMIZATION FUNDAMENTALS 13
Intuitively therc is some concem with the problem as expressed
by Equations (1.13(1.15)even thoughdescriptionis valid. How can the
value of the design variable t be estab1ished? The variation in t
does not a'ectthe design. Changing the value of t does not changef
hl or glHenceit cannot be a design variable. (Note: the variation
in t may affect the value of c.) lfiswerc a practical design
problcm then canshave to be designed for impact and stacking
strength. InCet will probably be a critical design variable. This
will require severadditionals cluralconstraints in the problem. It
could serve as an interesting extension to this problem for
homework or projectleoptimization problem after dropping t
dexpressing [d. h] [XIX2]becomes:
???
?
? ? ? ? ?L ?
? ? ?gM.h.t): 2d-h SO
6Sds9; 5s/ts20; O.OOIStsO.Ol (1.15)
Flgure 1.2 Example 1.2-Canlllever beam.
Minimize f(XIX2): c: ( 1.16)
(1.17)
gl(lXU:2x1-X2S0 (1.18)
lntuitivelyelarger the value of F. the greater
iscros8-Secllionaalare=anecsvt.0 handleit. 11 canbeilyconcluded
atifFw adsibselat its lower limit a8 lhe mass of the beam will be
direclly proportional 10earea of croS8 8cc(Iun. No techniques are
ruiredf.or lhis conclusi.on. By .our definition F is a go.od
candidate as a parneterrather asa design variable. Similarly the
larger the value of Legateris the momentFgenerates about the
cantilevered end.liswill require an increase inearea .of
cross-section. Therefore L is not a good choice f.oredesign
variable either as the best choice f.or it will bc il.owerIimit. To
represcnt material as a design variable. we necd to use its
SlruClural propcrties ineformulalion ofthe problem. Typically. a
malerial is characlerized by its specc
Subjecllo: hl(xlXv:ru/4-500=0
6 SX) S 9; 5 SX2 S 20
The problempresenledby Equati.ons (1.16)(1.18)is
mathematicalmode f.or thdesignproblem expressed in the slandard
format. For this problem no extranc.ous informali.on was ndto set
upeproblem except for some geometrical relations.
Example 1.2 A cantilever beam needs 10 be designed to crya point
load F al the end .of the beam .of lenglh L. The cross section of
the beam wiII be in the shape of the letter 1 (ferredto as
1bm).lebeam should meet prescribed failure criteria. Thcre is also
a Iimit on its deflecti.on. A beam of minimum mass isquired10 be
digncd. Figure 1.2 shows a side view .of the beam carrying the load
and Figure 1.3 a typical
cr.oss snofthben.The I-shaped cross section is symmetric. The
symbols d tw. br and tr c.orrespond to the dep.ofthe bcam thickness
of the web width of thflangeand thickness .of the flange
respectively. Thesquantitiesare sufficient to defineEcr.oss
section. A handbo.ok or textb.ook on strcngth of materials can
aidedvelopment.of thdesignfunctions. An important assumption for
this problem iswe will be w.orking within the elastic Iimit of thc
material where there is a Iinear relati.onship betweenestress and
the strain. AlI .of the variables identified in Figure 1.3 will s
nglyaffect the soluti.on. They are design variables. The applied
f.orce F will also directly affect the problem. So will its
locati.on L. H.ow aboutmaterial?Stecl is dcfinitely supcri.or 1.0
c.opper for the beam. Should F L and the material pr.operties be
included as design variables?
bt I~ 'l
4tW-
Flguro 1.3 Example 1.2-Cross-sectlonal shape.
-
14 INTRODUCTION
weight y its value ofthe modulus of elasticity. E. its modulus
of rigidity. G. its yield limit in tension and compr
sion.yie'd.iyield in shyield.its ultimate strengin tension.ult. and
its ultimate strength in shear.ullOptimi liontechniques identify
diffentva1ues of the design variables. If E is the variable used
topresentEmaterial design variable in a problem. then it is
possible the solution canquirea materia1atdoes not existatis. a
va1ue of E still undiscoverd.For a11 intents and pposes.isis beyond
the scope of the designer. Again. materia1 as a parameter makes a
lot of.sense andeoptimization problem should be reinvestigated if
For the material changes. Concluding fromisdiscussion on modeling.
the following Iist can be established for this example:
Design p1eters F.L.{y.G. Y'eld'1:yield'u11'1:EDesign variables:
d tw' br'If
In the devlopmentof the mathematical model standard technical
definitionsused. Much of the information can be obtained from a
mechanical engineering handbook. Thfirstdesign function isweightof
the beam. This is the product of y L and Ac where Ac isearea of
cross section. The maximum slress due to bending ""nd can be
calculated as the product of FLdI21cwhereisthc momenl of inertia
about thc ccntroid of the cross section along the axis parallel to
the f1ange. The m imumshear stress incrosssection is expressed as
FQcllc1w wherc Qc is first moment of area about the cenidparallcl
to thc flange. The maximum deflection (~) of the beam wi11 be at
the end of the beam calculated by the expression FL3/3Elc' Ac of
the cross section of the beam is 2brtr + Iw (d -2tf). The first
momcnt of area Qc can bc calculated as 0.5bftf (d -tr) + 0.51w
(0.5d -tf)2. Finally.cmomcnt of inertiais obtained from (b112)
((br-tw )(d -2tf)3/12). In followingfor convcnience we will
continue to use Ae Qc' andinstcad of detai1ing their dependence
onedesign va1ues. Associating x with d X2 with tw' X3 with br and
X4 with lr soatX=[xX2X3'x41eproblem in standard format is
Minimize .ftX): YLAC ( 1.19)
Subject to: g(X): FLx/21c-yie'd ~ 0
g2(x):FQJ1.x:x2-1:yieeg3(X):FL3'/3Elc 3m ~O0.0 1 ~ x ~ 0.25; 0.00 1
~ X2 ~ 0.05; 0.0 1 ~ X3 ~ 0.25; 0.00 1 ~ X4 ~ 0.05
(1.20)
To solveisproblem F must bc prescribed (10000 N) L must be givcn
(3 m). Matcria1 must bc selected (stee1 := 7860 kglm3; O"yield =
250 E+06 N/m2;yicld = 145 E+06 N/m2). A1so the maximum dct1ection
is prcscribcd (amn~ = 0.005 m).
??????
??
? ? ?
?? ? ?
???
? ???? ? ?
????????
1.1 OPTIMIZA TION FUNDAMENTALS 15
This is an example with four design variables three inequality
constraints. and no equality constraints. Othcr vcrsions of this
problem can easily be formulated. It can be reduced to a
two-variablc problcm. Standard failure criteria with respect to
combined stresscs or principa1 strcsses can bc formulated. If the
cantilevered end is bolted then additiona1 design functions
regarding bolt failure need to be exarned.
Example 1.3 MyPC Company has decided to invest $12 million in
acquiring severa1 ncw Component P1acement Machines to manufacture
dierentkinds of moeoardsfor a new generation of personal computers.
Three models of these machines are under consideration. Tota1
number of operators available is 100 becausc ofelocal labor market.
A floor space constraint needs to be satisfied because ofedifferent
dimensions of semachines. Additiona1 information relating to each
ofemachines is given in Table 1.1.ecompany wishes to determine how
m yofeach kind is appropriate to maximizc the number of boards
manufactudperday. lt is difficu1t to use a figure in this problem
to sct up our mathematical model. The
number of machines of cach model necds to be determined. This
will serve as our design variables. Let XI represent thnumberof
Component Placement Machines of Model A. Similarly X2 wi1l be
associatcd with Model B and X3 with Model C.
??
D igllvariubles: xX2X3The infonnation in Table 1.1 is used to
set up the design functions in terms ofedesign variables. An
assumplion is made that all machines are run for three shs.The cost
of acquisition of the machines is the sum ofecost per machine
mu1tiplied by numberof machines (g 1)' Thmachinesmust satisfyefloor
spacc constraint (82) which is defined without details in Eq.
(1.23). The constraint on the number of opemtors is three timcs
sumofeproduct of the number of machines of chmodel and the
operators per shift (g3)' The utilization of each machine is the
number of boards per hour times the number of hours the machine
operates per day. Thc optimization problem can be assembled
infollowingform:
f
s
Maimizef(X):18 x55xxl+18x50x~+2Ix50xx3 (1.21)
or
T Minimize f(X):-18 x 55 x x -18 x 50 X x2 -21 X 50 xX3 Suctto:
g(X): 400OOOx + 600.000X2 + 700000X3 ~ 120 000 (1.22)
g2(X): 3x -X2 + X3 ~ 30 (1.23) 83(X): 3xI + 6X2 + 6x3 ~ 100
(1.24)
XI ~ 0; X2 ~ 0; X) ~ 0
-
? ? ? ? ? ?
?????
-61'.1.Y:.iK.~17
9
OPTrMIZATION FUNDAMENTALS
6
1.1
5
INTRODUCTION
Equations (1.21)(1.24)express mathematicalmodel of the problem.
Note tinthis problem there is no product bcing dcsigned. Here a
strategy for placing order for numberof machines is being
dctermined. Equation (1.21) illusthetranslation of the m
imizationobjective into anuivalentminimizing one. The inequality
constraints in Equations (1.22)(1.24)are different from the
previous two exnples.He theright-hand side of the S operator is
nonzero. Similarly the side constraints are bound on the lower side
only. This is done deliberately. There is a significanl difference
betweenisproblem and the previous two. All of the design functions
here are linear. This problem is c1assified as a linear
prograrnming problem. The solutions 10 these typcs of problems are
very different than thc solution 10 thc first two cxamplswhich are
recognized as nonlinarprogramming problms.
1.1.3 Nature of Solution
leecxarnpIsincprevious section arc used to discussenature of
solutions the optimization problem. Exarnples 1.1 and 1.2
dcscribeenonlinrprogramming problcm which forms the major part
ofisbook. Exarnple 1.3 is a lincar programming problem which is
very significant in dccision scicnccs but ra inproduct design. Its
inc1usion here while necessary for complctcness is also important
for understanding contemporary optimization techniques for
nonlinear programming problcms. Exarnples 1.1 and 1.2a dealtwith
ftrSt. Between the lwo we notice that Exarnple 1.1 is quite simple
relative to Exarnple 1.2. Second the four variables in Example 1.2
make it difficult to use i1lustration to establish some of thc
discussion.
16
G~hlIrepresentation 01 Example 1.1.
boofthesc functions.leualityconstraint gl is lincar. ln Equation
(1.18)isis evidentbause the desi variablesappcar byemselveswithout
being raised 10 a powcr o1.As we developetechniques for applying
optimizationisdistinction is important to keep in mind. It is also
significant graphicalrepresentation is typically restricted to two
variables. Forreevariables we need a fourth dimension 10 resolve
the informalIon and three-dimensional conlour plots are not easy to
iIIustrate. The power of imagination is necessary to
overcomesehurdles. 1problemreprcsented in Figure 1.5 providcs
opportunityto identify the graphical
solution. First the feasible region is identified. In Figure
1.5isisEualityconsintabove the incquality consint.Bothfeible and
oplimal must occur from this :gion.Any solution fromisregion is an
acceplable (sible)solution. There are usually a large number of
such solutions infinilesolutions. If optimization is involved thcn
thesc choices must be rcduced to the best one withspcctto some
criteria theobjeclive. 1n this problemlfigure the smallcst value
offis desired. The lowest valuc of f is just less than the contour
value of 308. lt is ateintersection of the two constraints. While
the value of f needs to be calculated the optimal values of the
design variables read from the figure are about6.75 and 13.5
respectively. Another significant item of information obtained from
Figure 1.5 is glis an active constraint. While there are infinite
feasible solutions 10 thc problem the optimal solution is
Ultique.
Flgure 1.4
? ? ? ? ? ? ?
???
[~ 5
SOLUT10N TO EXAMPLE 1.1 Thc simplcst determination of
nonlinearity is through a graphical Psentationofcdcsign functions
involved in thc problem. liscan be donc silyfor ODe or two
variables. If the fUDCtiOD does not plot as a straight line or a
planeenit is nonlincar. Figu 1.4shows a three-dimcnsional plot of
Examplc 1.1. The figure is obtained using MATLAB. Chapter 2 will
providdctailcdinstructions for drawing such plots for graphical
optimization. The threc-dimcnsional pr entationof Exarnple 1.1 in
Figure 1.4 does not real1y enhance our understanding of the problem
or the solution. Figure 1.5 is an altemate repscntationof the
problem. This is thoneencouraged in this book. Thc horizontal
isrepscntsthe diameter (XI) and verticalaxiseheight (xu. 1n Figure
1.5 the equaliconstraintis markcd appropriately as h 1. Any prof
valucs onisline will give a volume of 500 cm3 The inequa/ity
constraint is shown as g 1. The pair of values on this line exact1y
satisfies thc aeseticrequiment.Hash lines on the side of the
inequality constraint cstablish the disallowedgionfor the design
variables.leconstraints are drawn thicker for emph is.The scaled
0'eclivenClionis reprendthrough sevcral labelcd contours. Each
contour is associated with axedvalue of the objcctive function and
these values are shown on the figure.lerange of the two axes
establishes the side COllStraints. The objective functionf and the
equalily constraint h 1 'cnonlinear sincc they do not plot IIS
straight lines. Rcferring to Equations (1.16) and (1.17) this is
substantiated by the pl'OduCIS of the two unknowns (design
varillbles) in
-
19
An interesting observation in the above set of equations
isatthere are only two design variables but three constraints. This
is a valid problem. If the constraints were equality
constraintsenthis would not be an acceptable problem definition as
it would violateerelationship between the number of variables and
the number of equality constraints. Therefore the number of
inequaliconstraints are not related to the numbrof design variables
used. This fact also applies to nonlinear constrnints. Figure 1.6
is a scaled plot ofcfunctions (1.25)(1.28).Choosing the first
quadrant satisfies the side constraints. 'he linearity of all of
the functions is indicated by the straight-line plots on the
figure. Again several contours offare shown to aid the recognition
ofthe solution. All of the inequalities are drawn with hash marks
indicating the nonfeasib1e side of the constraint. The feasible
region is enclosed by the two axes along with constraints g2 and
g3' The objective is to increasthevalue off(which is indicated by
the contour levels) without leaving the feasible region. The
solution can be
(1.28)
1.1 OPTIMIZATION FUNOAMENTALS
83(X): 3xI + 6x2 ~ 70
X2~0 X1 ~O;
????????
????
INTROOUCTION 18
20
? ? ? ?
??
25 20
Conlour plol 01 modllled Example 1.3.
1S number 01 Model A
10
Flgure 1.6
5
9
SOLUTION TO EXAMPLE 1.3 In contrast to Example 1.1 all of the
relationships in mathematicalmodel expressed by Equations
(1.21)(1.24)are linear. The word equation is generally used to
describe the equivalence of two quantities on either side of the =
sign. In optirnization we come across mostly inequalities.eword
equatioll will beedto include both of these situations. In Example
1.1enaof solution was explained using Figu1.5.In Example 1.3 the
psenceof thrdesign variables deniesisapproach. Instead of designing
a new problem suppose thecompany psidenthas d idedto buy five
machines of the third type. The mathematical model with two design
variables Xl and X2' is reconstructed using the information that X3
is now a parameter with the value of 5. Substituting for x3 in the
model for Example 1.3 and cleaning up the first cons int:
M imize
Subject to:
(1.25)
(1.26)
( 1.27)
H137 8.5
j(X): 990 XXI + 9xX2+5250
Conlour plol 01 Example 1.1.
gl):O.4xl + 0.6x2 ~ 8.5
7.5 dlameler (cm)
g2(X): 3xI -X2 ~ 25
7
Agure 1.5
6.5 5 6
-
20 lNTRODUCT10N
spottcd at the intersection of constraints g2 dg3. The values of
the design variIcsat the solution can be read off from thc plot. It
is not over yet. Before proceeding further il is neccssary to
acknowledgc that a solution of 6.5 machines for Model B is
unacceptable. The solution must be adjusted to the ncarest integer
values. In aClual practice. this adjustmcnt has to bc made without
violating any of the constraints. The need for integer variables is
an important consideration in dcsign. Vablesatarquiredto have only
integer values belong toetype of variables called discrete
variables.'his book most1y considers continuous variables. Almost
a11 of the mathematics an engin rencounters especially academically
belong toEdomain of continuous variables. Thc assumption of
continuity providcs very fast and cfficicnt techniques for the
search of constrained optimum solutions as we will develop in this
text. Many real-Iifc designs especially those that use
off-the-shelf materials and components determine discrete models.
Discrete programming and integer programming are disciplines that
address these models. The nature ofsearch methodsatis methods used
for searchingeoptimal solution in discrctc prograrnming is very
different fromatin continuous programming. Many of thmethods are
based on the scanning and replacement of the solutions through
exhauslive search of the design space in the design region. In this
book disctcproblems arc typically handled as if they were
continuous problems. The conversion toediscrcte solution is the
final part of the design effort and is usually performed by the
designer outsidofany optimization technique we develop in this
book. Chapter 8 discusses discrete optimization with examples.
Getting back toelinear programming problem just discussed it
should also be noted that only the boundary of the feasible region
will affect the solution. He isa way that will makeisapparcnt. Note
that the objctivefunction contours arstraightlines. A different
objective function will be displayed by parallellines with a
different slope. Imagine these Iines on the figure instead of the
actllal objective. Noteatthe solution always appears to lie at
thintcrsectionof the constraints that is thcornersofthedsignspacc.
Solution can nevcr comfrominside of the fcasible gionunlike in the
nonlinear programming problem which accommodates solution on the
boundary and from within the feasible region. Recognizing thc natu
ofsolutions is important in developing a search procedure. For
example in linear prograrnming problems a technique employcd to
search for the optimal dsignneed only search thc boundaries
particularly the intcrsection of the boundaries whereas
nonlinearproblems the search procedure cannot ignore interior
values.
1.1.4 Characterlstlcs of the Search Procedure
lesearch for the optimal solution will depend onenature of the
problem being solved. For nonlinear problems it must consider the
fact that solution could lie inside the feasible region. Example
1.1 throllgh Figurc 1.5 will provideecontext for discussing the
scarch procedure for nonlincar problems. Simi1arIy the
characteristics
1.1 OPT1M1ZAT10N FUNDAMENTALS 21
of the search process for linear problcms will be explored using
Ex lple1.3 and Figure 1.6.
????? ??
?
? ? ?
? ? ? ? ?
??
? ?? ? ?
? ??
?
Nonllnear Prob/ems: Except for a few c1asses of problcms
solutions to non1inear problems are obtained through numerical
analysis. Through computr code numerica1 analysis becomes numcrical
techniques. The methods or techniques for finding the solution to
optimization prob1ems are called search methods. In applied
mathematics and numerical thniquesthese referredto as iterative
techniques. Implicit1y this means seveml tries will be necessary
beforc the solution can be obtained. A1so implied is that cach try
or search is executed in a consistent manner. Information from
previousiteration is utilized in the computation of values in the
present sequence. This consistcnt manner or press by which the
search is carried out and solutiondetermined is ca1ed
algorithm.This term a1so refers to the tr slationof the particular
search procedure into an ordered suenceof step-bystepactions. The
advantage is derived mostly in the conversion of these steps
through some computer 1anguage into codeatwi1l execute onecomputcr.
DevelopingEa1gorithm and trans1ating it into code that wil execute
in MATLAB wil be a standard approach inisbook. The search process
is started typica1y by trying to guess thinitialdesign
solution.
The designer can base this selection on his experience. On
sevcm1 occasions the success of optimization may hinge on his
ability to choose a good initial solution. The search method even
when used consistent1y responds different1y to the particular
problematis being solved. The degree and type of nonlinearity may
frequent1y causeemethod to fail assurning there are no
inconsistencies in problem formu1ation. Oftennumberof design
variablesenumber of cons intsas we1 as a bad initial guess p1ay a
part in unexpected behavior under standard imDlementation of the
method. This has led to the creation of seveml differcnt techniques
for optimization. Practica1 experience bas a1so suggestedata class
of problems respond well to certain a1gorithms. The mcthods
foresearch or itmtivemethods. are current1y the only way to
implement numerical solutions to nonlinear problems irrespective
of the discipline in which these problems app r.1eproblems are
p1entifu1 in design optimization. optimal contro1. structural and
t1uid mechanics. quantum physics. and astronomy. Whi1e optimization
techniques are appliedallof the noted disciplines. in
ditionaldesign
-
23
at a distan sS..This point satisfies the constraint h..
AirdsYwould be to choosc X.Thislies on the constraint boundary of
g.. lt is to be noted that allEchoices are not feasible. Which
point is chosen is dccided by the rules of a particular algorithm.
Assume point X) is the next point inisdiscussion. Point X) now
becomes newpoint xoAnewhdircction ~ is dennin.
Point X2 is 10d.Anoth Suenceof calculations locat X3 lenext
iteration yields esolution. The essence of updatingedesi
duringsucssiveiteration lies in two major computations thc
seahdirectioll 8/ and stepsize.lCchange inedesign vector definIas
.6X which representsveclordiffcrence for exnpleX2 -X. is obtained
asS/. For each iteration the following suenceof activity can be
identified:
The above is the basic structure of a typical optimization
algorithm. A complete one will indicate m nerin which S and are
computed. Il wil1 incJude tests which will determinc if solutionhas
bcen reached (convergence) or if the procedure needs to be
suspended or restarted. The diffcrent techniques to bexplorcdin
this book mostly differ ineway S is established. Take a look at
Figure 1.7 again. At Xo there are infinite choices for the search
direction. To reach the solution in onabletime an acceptable
algorithm will try not to search along directionsdonot improve the
current design.lereare many ways to accomplishisstrategy.
1.1 OPTIMIZATION FUNDAMENTALS
ChooseXo Identify S Determine AX=S XMW= Xo+.6X SetXo Xnen
GoToStepO
8tep 0: Step 1:
:r;-:.
INTRODUCTION
FJgure 1.7
g 8.5
A typical ssarch method.
7.5 dlamoler (cm)
22
20
5 6
? ? ? ?
Linear Programming Problem: It was previously
mentionedthesolution to seproblems would be on the boundary of
feasiblegioo(also called the jibledomain). In Figure 1.6e esand
some of the cons intsdetennine this region. The lalter is
distinguished also byepoints of interscction of the constrainLs
among themselveseorigin andeintersection of the binding (active)
coostraints with the axes. These are vertices or corners of the
quadrilateral. Essentially the design improves by moving from one
of these vertices to the next one through improving feasible
designs. To do that you have to start at a feasiblcomer.This will
be explored more fully in the chapter on linear programming. It is
to be emphasizedatonlywith two variables can we actually see the
geometric iIIustration of the techniqueisthe selection of vertices
as the solution converges.
This part of Chapter 1 has dealt with the introduction of the
optionproblem. While it was approached from an engineering design
perspcctive the mathematical model in abstract terms is not
sensitive to any pticulardiscipline. A few design rules with resp
tto specific examples were examined. TIle standard mathematical
model for optimization problems was established. Two broad cJasses
of problems
initial startingessisepoint marked xoRemember
whensolvingoptimization problem. such a figure does notist.If it
didenwe can easily obtain the solution by inspection.lisstatement
is espccially true ifereare more than two variables. In the event
th aretwo variables isno reason not to obtain a graphical solution
(Chapter 2). Thc mcthods in optimization rely on thc dircct ex
polationof the concepts and ideas develodfor two variables to any
number of design variables. That is the reason we will use two
variables to discuss and design most of the algorithms and methods.
Moreover using two variablesconceptscan also be reinfordusing
geometry. The design at the point Xo is not feasible. lt is not
useful to discuss whether it is an optimal solution. At least one
more iteration is necessary to obnthe solution. Considerenext
solution at XI. Most methods in optimization will attempt to move
to X I by first identifying a search direction S 1Thisis a vector
(same dimension as design variable vcctor X) poimXoloXIeactual
distance from xo to XIcallit XoX.. is some multiple of SI' s
SIX10nceagain is not feasible altbough it is an improvement on xo
since it satisEincqualily constrainl gl (lying in lhe inlerior
ofeconstraint). Altemately using lhe same scal'ch dircction S 1
another techniqueJmeodmay choose for its next point X 1'
-
.1""':-......1: n' '
24 INTRODUCTION
linear and nonlinear. were introduc.Thegeomeicalcharacteristics
of the solution for thesc problems were
shownroughgraphicaldescription ofeproblems. An overview ofesearch
techniques for obtaining the solution to these problems w also
iIIustrated. It was a1so mentionedatesolutions were to be obtained
numerical.primarily through digital computation. The numerical
methods used inisarea are iterative methods. Numerical
solutions
involve two components: algorithmthat willstablish iterativeset
of calculations. and second. the translation of the algorithm into
computer codes. using aprogramming lang 'ge.This finished code is
referred to software.Until recently in engineering education as
well as practice. the compurlanguage of choice was predominantly
FORTRAN with a Iittle Pascal and C. The computational environment
in which it was delivered and practiced wemai'amecomputing systems.
Today escene is very different. Individual personal
computersCs)running Windows Macintosh LINUX or other flavors of
UNIX operating systems are now the means for technical computing.
They possess more power than the old mainamecomputers and they are
inexpensive. The power of the graphical user interface (GUI)eway
euser interacts withecomputer andesoftware h revolutionizedthe
creation of software today. New programming
paradigmsa11y0'ecloriented programming have led to new and improved
ways to develop software. Today cnginccring softwarc is crcatcd by
Buch gcncl'al programming languagcs IlS C C++ Java Pascal and
Visual Basic. Many software vendors develop their own extensiol1s
to the standard language providing a comple1environmentfor software
devlopmentbyeuser. This makes it very convenient for users who are
not necessarily programmers to geteirjob done in a reasonab1y short
time. One such vendor is MaWoswitheirflagship product MA TLAB a10ng
with a
complementary collection of toolboxesatdeliver specific
discipline-oriented information. InisbkMATLAB is used exclusively
for numerical support. No prior familiarity with MATLAB is expected
though familiarity with the PC is required. Like all
higher-1cvcllanguages effectiveness with this new programming
resource comes with effort frequency of use. original work and a
consistent manner of application. By the cnd of this book it is
hoped theaderwill be very familiar with thc u
1.2 INTRODUCTION TO MA11.AII 25
1.2 INTRODUCTlON TO MATLAB
???
????
????
MATLAB is introduccd by MathWorks Inc. as the language for
technical computing. Borrowing from the description in yone of its
manuals MATLAB integrates mputation visualizatiodprogramming in an
easy-touseenvironment where problems and solulions are expressed in
farniliar mathematical notation. The typical uses for MATI..AD
includ
Math and computation
A1goritllmdevelopment Modeling simulation and prototyping Data
analysis exploration. and visualization Scientificand engineering
graphics Application development including GUI building
The use ofMATI..AB has exploded recently and so have ifeatures.
Tbis continuous enhancement makes MATI..AB an ideal vehicle for
exploring problems in all disciplines that manipu1ate mathematical
content. This abi1ity is multiplied by application-specific
solutions through toolboxes. To learn more about the latest
MATI..AB. its features the toolboxes collection of user-supported
archives information about Usenet activities other forums
information about books and 80 on visit MATLAIl a1
hup:/lwww.ma1hworks.com.
1.2.1 Why MA11.AB?
MATLAB is a standard tool for in'oductoryand advanced courses in
mathematics engineering and science in many universities
aroundworld.In industry it is a too1 of choice for reshdevelopment
and analysis. Inisbook MATLAB'S basic array element is exploited to
manipulate vectors and matrices that are natural to numerical
techniques. In the next chapter its powerful visualization features
are used for graphical optimization. Inerest of this book the
interactive featurldbuilt-in support of MATLAB are utilized to
translate a1gorithms into functioning code in a fraction of the
time needed in other languages like C or FORTRAN. Towardeendwe will
inoducethe use of its Optimi tionToolbox. Most books on
optimization provide excellntcoverage on the ~hniques and
a1gorithms and some a1so provide a printed version of the code.
The code isquidto be used in mainfmmEor legacy environments that
must support a compiler in the languageecode is written which is
predominantly FORTRAN. Each studentenanslatesthe orinted code into
a forrn suitable for computation.lenext step is to compile the code
debug compilation errors run programand troublhoot execution crrors
before usefulsultscan be obtained. An important consideration is
thestudent is expected to be conversant witheprogramming language.
While FORTRAN was formally taught to enginrsseveral yrsagoisis no
longer true.
-
7 -
26 INTRODUCTION
Many electrical engineering departments have started to embrace
C and C++. PCs are great for the use of ready-made applications
especially those with GUI but its use for programming in FORTRAN
has yet to take off. MATI..AB suffers very few of these
disadvantages. Its de is compact ditisinitive
to leam. To make problems work requires few lines of code
compared to traditional languages. Instead of programming
fromeground up stanrdMA TI..AB pieces of code
canbeadedtogeerimplementthe new algorithm. It avoids the
sndard:pru:mpilation and link suenceby using inte.reter.Another
importantasoniscode po bility.ledewritten forePC version ofMATI.AB
dsnot have to be changed for the Macintosh or the UNIX
systcms.liswill not be true if system-dependent resources
medinece.As an ilIustration of MATI.AB'S leaming agility
boMATI.ABdapplied optimization arevered in this book something very
diffictaomplishwisay FORTRAN and optimization or C++doptimization.
FlermoreIA'..ABlike C or FORTRAN is a globally relevant
product.
1.2.2 MATLAB Installalion Issues
This book does not Care if you are running MATLAB on an
individual PC or Mac a networked PC or Mac or individual or
networked Unix workstatioJls. MATLAB takcs care of this issu.The
book assumes you have a working and appropriately Iicensed copy of
MATLAB in the machine inontof you. On your personal machine for
installing MATI.AB follow the instructions that accompanidthe box.
Typicallyesystem administrator handles network installations. This
book uses MATt.AB Version 5.2 (until Chapter 4) and Version 5.3
(erest).
Version 6 has been shipping since the fall of 2000. MAABversion
5.0 and above should work. If MATI.AB has changed any built-in
commands in newer versionsthe oneedin the book it should provide
information on the availability of newer version of commands(or
lhrow an error a rare case). The MATLAB code and examples were
created on an Inlel Pentium Pro 200 running the Windows NT 4
operating syslem. The earlier codes were also tested on a DEC Alpha
server running OSFl V4. The MATI..AB version on the server was 5.1.
In organizations and instilutions MATt.AB software is usually
licensed on a
subscription basis. Users therefore havthe1atest version of the
software in these situations. In such a case the new version
(attimethe book is first published) will be Version 6 (or Release R
12). This book is based on Version 5 (Release RI1).lecode
dprogramminginstructions in the book shou1d execute withoUl problem
in the new version. In the new Release R12 on the PC p1atform the
default appearance of MATI..AB is a composite of several windows
presenting different pieces of information. This is shown in Figure
1.8. This c becustomized through the menu b byView Desktop
LayoutCommand Window Only which also coponds toeprevious1ease.It is
shown in Figure 1.9.lisview is simple and less distracting for
getting familiar wiMATl..AB.NoteeMATt.AB command prompt is
>>. This window delivers standard operating system commands
for saving printing opening files and so on lhrough menus and a
command bar. In order to
T
h' m.
f.
1.2 INTRODucnON TO MATl.AB 27
F1gure 1.8 MATLAB opening view.
create files (or code) another graphica1 window is neded.This
iseMATLABMfileeditor/debugger window and is shown in Figu1.10.The
editor uses co10r for enhancing code readability. Each of
thesewindows spawn additiona1 dia10g boxes (if
nec)fior.sctttin1gfieatureesduIriirworkspace browser. While this is
not so much as an installation issue it wou1d be appropriale lo
discusse
waykplaI1s to wriandexec MATI.ABC Gen yereare two ways to
workMATI.AB:interactivelyand thro'pts.In interactive
mode.rnn1andsareented dutedone at a time in the MATt.AB cOrnn1and
window. Oncesess10nis over and MATt.AB exited there is no
information 1tainedonset of commandswere used and what worked
(unless a choice was made to save the session). Large seauensof
cOrnn1aI1ds are usually dicu1u.okPackofinEeracUvsess10n.4o
optifilein MATI.ABThisis called a script m-ftle. Most MATLAB
fillledm-ftles. The m is a meextBIESion usually mserved for
MA-I-LAB.Any code changEsmemade thmush eeditor. the changes to
efile saved and e filcexecudin MATt.AB again. ExcutinMATt.ABtl
ghscdptmleesispredom1lintorevertto interactive mode any time.
1.2.3 Using MATLAB the First Time
Eg
MATwil be used inte ive1yinissection. The au.thor
verynyrecornn1ends a hands-on approach to understanding
MATt.ABThismeans typmg tt1e codes yourself. It a1so inc1udes
underslanding the syntaxrrorsand debugging and
-
28 INTRODUCTION
isis a Classtoom License fOt insttuctional use only. Reseatch
and cometcialuse is ptohib1ted.
To qet statted select "HATLAB Help" ftom .the Help menu.
Flgure 1.9 MATLAB Command wlndow.
Optim1zation11~IATtAB 'iI John ~iley Dt.P. VenkataJ;amenl
F1gure 1.10 MaUab Editor/Debugger window.
1.2 INTRODUCTION TO MAlUB 29
rectiringecode. The author is not aware of a single example
where programming was learned without the reader typing de.lnisbk
MATLAB code segments are courier font withebold style lIsed for
emphasizing commands or other pieces of information. Anything else
is recommendations suggestions or exercises. The placeholder for
command is in italic.
l
Before We Start: The folowing punctuation dspecial characters
are worth noting:
Al text after the % sign is considered a comment. MATLAB ignores
anything to the right of the % sign. Comments are used liberally in
this book to indicate why's and what's of command or code usage. Do
not overlook them. You do not have to code them in however probably
two weeks later you wil not remember why you developed that
particular piece of code. This is the default MATLAB prompt. A
semicolon at the end of a line prevents MA ABfrom echoing the
information you enter on the screen. A comma will cause the
information to
A
. J
h. U
>>
????
?????
??
echo. Default is a comma. A succession of three periods at the
end of the line informs MATLAB codewill continue the next line. You
cannot split a variable name across two lines.You cannot continue a
comment on another Iin.You can sto'pMATLAB execution and get back
thcomm!mdpromptbytyping ^c (Cl-C)byh01dingdowntogeer.WilI display
information on the various ways the command can be used. This is
the quickest way to use help. Opens a help text window that
provides more information on all of the MATLAB resources installed
on your system. Provides help using a browser window.
?? ?? ? ? ? ?
?? ?????????
?
A c
>> help command_name
>> helpwin
>> helpdesk
-
30 INTAODUCTION
For those of you programming for the first time the equal to
sign (=) has a very special meaning in all programming languages
incJuding MATLAB. It is called the assignment operalor.levariable
on thc Icft-hand side of the sign is assigned the value
oferight-hand side. Thc actual eqllallO operation in MATLAB is
usually accomplished by a double cqual to sign (==).
Some Additionsl Features
MA ABis case sensitive. An a is different than A. This is
difficult for persons who arc uscd to FORTRAN. All built-in MATLAB
commands arc in lowercase.
MATLAB does not necd a type definition or a dimension statement
to introduce variables. It automatically crtesone on first
encounter in code. The type is assigned in context
Variablnamesstart with a letter and contain up to 31 cbaractcrs
(only Icttrsdigits and underscorc).
MATLAB uscs some built-in variable names. Avoid using built-in
variable nam.
All numbers arc storcd internally using the long format
spccificd by IEEE f1oating-point standard. These numbers have
roughly a precision of 16 decimal digits. They range roughly
between 10E-308 and 10E+308. Howeveyaredisplayed differcntly
depending on the context.
MATLAB uses conventional decimal notation for numbers using
decimal points and leading signs optionally for example 1 -9 +9.0
0.001 99.9999.
Scientific notation is cxprcssed with the letter e for cxample
2.0e-03 1.07e23 1.732e+03.
lmaginary numbers use either i or ja suffix for example li
-3.l4j 3e5i.
Operators: The following arc the arithmetic operators in
MATLAB.
+ Addition (wben adding matriccs/arrays size must match)
Subaction(same as above)
* Multiplication (the subscripts of arrays must be consistent
when multiplying them)
/ Division Power Complcx cougattranspose(0 aytranspose)
In the case of arrays each of these operators can be used
wiaperiod prefixed toeoperator for cxample ( . * ) or ( ^ ) or
(1).hasa special meaning in MATLAB. It
imp1ieslement-by-elementoperation. It is uscful for quick
computation. It has no
"
1.2 INTAODUCTlON TO MATlAD 31
relevance in mathematics or anywhere else. We wiJ1 usc it a lot
in the next chapter for gClIerating data for graphical
opzation.
An Interactlve Sesslon: SMA AB.On PCprcss the Start button.
Press the Program button. Prcss thc MATLAB 'gramGroup. Press MA
TLAB. The MATLAB Command window opens up and after somc
introductory messagesE willbe a MATLAB promptindidby double forward
arrow.lisis indicationMATLABis ready to aeptyourmmands. On the
networked stionstyping matJab at the window prompt should do the
same. Note that the MATLAB program must be in the paasdefmed
ine.Iogin or.h file.Ask the lab assistant for help. ThestandardUNIX
proccdtrnat the end ofelinc or befoecomment. The commcnts rclatc to
what is being typed dwhat is displayed in the MATLAB command
window. FI1frccyourown variatiosS. In fact to
undedandreinfocommandsit is commendedyou make up your own examples
often.
>>a 1.0; b 2.0; c 3.0 d 4.0; e 5.0 >> whydid only c
and e echo on the screen? >> who listsall the variables in
the workspace >> a givesthe value stored in a >>A 1.5;
variableA >> a A % case matters >>one a; two b; three
C; >> assigningvalues to new variables >>four d; five
e; six pi; valueof pi available >> A1 [a b c ;' d e f] A1is a
2 by 3 matrix >> % space or comma separates columns >>
% semi-colon separates rows
>> A1(22) accessesthe Matrix element on the >> %
second row and second column >> size (A1l givesyou the size
of the matrix >> (rowcolumIlsl >>AA1 size(A1l
Whatshould happen here? >> fromprevious satementthe size of
A1 >> containstwo numbers organized as a row >>
matrix.This is assigned to AA1 >> size(AA1l AA1is a one by
two matrix >> A1' thistransposes the matrix A1 >>B1 A1'
thetranspose of matrix A1 >> isassigned to B1. B1 is a three
by two matrix >> C1 '" A1 * B1 SinceA1 and B1 are matrices
this >> i8a matrix multiplication >> Shouldthis
multiplication be allowed? >> considermatrix multiplication
in C or
-
32 INTRODUCTION
>> % Fortran >> thepower of MATLAB derives from its
>> abilityto handle matrices like numbers >>C2 81 * A1
Howabout this? >> C1 * C2 Whatabout this? >> % read the
error message >> itis quite informative >>D1 [1 2]'
D1is a column vector >>C3 [C1 D1] C1is augmented by an extra
column >>C3 [C3 C2(3 :)] Note is an assignment >>
meansdo the right hand side and overwrite the >>
oldinformation in C3 with the result >> ofthe right >>
handside calculation >> Onthe right you are adding a row to
current >> matrixC3. This row has the value of the third
>> rowof C2 -Notice the procedure of >> identifyingthe
third row. The colon >> % represents all the columns
>>C4 C2 * C3 permissiblemultiplication >> Notethe
presence of a scaling factor >> inthe displayed output
>>CS C2 * C3 seemsto multiplyl >> Isthere a difference
between C4 and CS? >> % The * represents the product of each
element >> ofC2 multiplied with the corresponding >>
elementof C3 >>C6 inverse(C2) % find the inverse of C2
>> apparentlyinverse is not a command in MATLAB >>
ifcommand name is known it is easy to obain>> help>>
lookfor inverse thiscommand will find all files >> whereit
comes across the word "inverse" in >> theinitial comment
lines >> Thecommand we need appears to be INV which >>
saysInverse of a Matrix >> % The actual command is in lower
case. To find >> outhow to use it -Now >> help inv %
shows how to use the command >> inv(C2) inverseof C2 >>
for i '" 1:20
f(i) i"'2; end
>> Thisis an example of a for loop
1.2 INTRODUCnON TO MAn.AD 33
>> theindex ranges from 1 to 20 in steps of >>
1(default) >> theloop is terminated with "end" >>
theprompt does not appear until "end" is >> entered>>
plot(sin(0.01*f)cos(0.03f)) >> xlabel('sin(O.Ol*f)')
stringsappear in single >> quotes>>
ylabel('cos(0.03*f)') >> legend ('Example') >> title
('A Plot Example') >> grid >> Theprevious set of
commands will create plot >> labelaxes write a legend title
and grid the >> plot>> exit finishedwihMATLAB
This completes the first session with MATLAB. Additiona1
commands and features will be encountered throughout the book.
Inissession it is evidentMA.ABalows easy manipulation of matrices
definitely in relation to other programming languages. Plotting is
not difficult either. These advantages arquitesubstantial in the
subject of optimization. 1n nextsession we wil1 use the editor 10
I1ccomplishesame through scripts. This session introduced
MATLAB Command window and Workspace
Variableassignment Basic matrix operations
Accessing rows and columns
Suppressing echoes
who inverse commands . * multiplication
Basic plotting commands
1.2.4 Using the Editor
In this section we will use the editor to tedrun a MATLAB a
script file. Norma1ly eeditor is used to generate two kinds
ofMA.ABfiles.1efiles are termed scriptftles andfunctionftles.
AIoughboofthsefiIes connMATLAB commands likeeoneswe have used the
second type of fiIes needs to be organized in a specified format.
Bofile tysshould have the extension .m. Although these files are
ASCII text fiIegeneric .m should beedbecaeMATLABshesforisex
sion.hisextension is quetoMA.AB.1cscript file contains a Iist of MA
TLAB commandsareexedin sequence. This is differentmthe interactive
session of the previous section where
-
34 INTRODUCTION
MA1.ABndedtochconunand immediately. The script file is more
useful when there armanyconun dsneedto be exutedto acmplish some
objective like running an optimization technique. It is important
to remember that MATLAB aIlows you to switch back interactive mode
at any time by just typing commands ineworkspacewindow like
inepvioussection. MATLAB provides an editor for creating these
files on the PC platform. This editor
uses color to identify MATLAB statements and elements. It
providesecurrent vaIues ofthe variables (aftereyare available in
the workspace) when the mouse is over the variable name in the
editor. Thel twoways to accesseeditor through the MATLAB Command
window on the PC. 5tart MATLAB. This will open a MATLAB Command or
Workspace window. In this window the editor can be started by using
the menu oretoolbar. On the File menu click on New and choose
M-fiIc. Altemately click on the Ieftmost icon on the toolbar
(etooltip reads New File). The icon for the editor can aIso be
placed on the desktop in which case the editor can be started by
double-clicking the icon. In this event a MATlAB Command window
will not be opened. The editor provides its own window for
enteringscriptstatements. At this point we are ready to use the
editor. Make sure youadcommentsand