100% found this document useful (1 vote)
171 views

Full Download Optimization Algorithms (MEAP V02) Alaa Khamis PDF DOCX

The document promotes the ebook 'Optimization Algorithms' by Alaa Khamis, which focuses on AI techniques for solving design, planning, and control problems using modern derivative-free algorithms. It is designed for practitioners with no prior knowledge of search and optimization, providing a comprehensive guide to various algorithms and their applications. The book includes practical examples, case studies, and Python implementations to help readers understand and apply optimization techniques effectively.

Uploaded by

rhmonisyuzn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
171 views

Full Download Optimization Algorithms (MEAP V02) Alaa Khamis PDF DOCX

The document promotes the ebook 'Optimization Algorithms' by Alaa Khamis, which focuses on AI techniques for solving design, planning, and control problems using modern derivative-free algorithms. It is designed for practitioners with no prior knowledge of search and optimization, providing a comprehensive guide to various algorithms and their applications. The book includes practical examples, case studies, and Python implementations to help readers understand and apply optimization techniques effectively.

Uploaded by

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

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

Optimization Algorithms (MEAP V02) Alaa Khamis

https://ebookmeta.com/product/optimization-algorithms-
meap-v02-alaa-khamis/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Smart Mobility Exploring Foundational Technologies and


Wider Impacts 1st Edition Alaa Khamis

https://ebookmeta.com/product/smart-mobility-exploring-foundational-
technologies-and-wider-impacts-1st-edition-alaa-khamis/

ebookmeta.com

Algorithms for Convex Optimization 1st Edition Vishnoi

https://ebookmeta.com/product/algorithms-for-convex-optimization-1st-
edition-vishnoi/

ebookmeta.com

Nature-Inspired Optimization Algorithms with Java: A Look


at Optimization Techniques Shashank Jain

https://ebookmeta.com/product/nature-inspired-optimization-algorithms-
with-java-a-look-at-optimization-techniques-shashank-jain/

ebookmeta.com

The New Spaghetti Cookbook: Delicious Spaghetti Recipes


for Pasta Lovers 2nd Edition Booksumo Press

https://ebookmeta.com/product/the-new-spaghetti-cookbook-delicious-
spaghetti-recipes-for-pasta-lovers-2nd-edition-booksumo-press/

ebookmeta.com
Understanding the New Proxy Wars 1st Edition Peter Bergen

https://ebookmeta.com/product/understanding-the-new-proxy-wars-1st-
edition-peter-bergen/

ebookmeta.com

Battle World A LitRPG Series 1st Edition Cassius Lange


Castor

https://ebookmeta.com/product/battle-world-a-litrpg-series-1st-
edition-cassius-lange-castor-2/

ebookmeta.com

CFA 2024 Level III - SchweserNotes Book 5 1st Edition


Kaplan Schweser

https://ebookmeta.com/product/cfa-2024-level-iii-schwesernotes-
book-5-1st-edition-kaplan-schweser/

ebookmeta.com

Quick Compendium of Clinical Pathology 4th Edition Daniel


D. Mais

https://ebookmeta.com/product/quick-compendium-of-clinical-
pathology-4th-edition-daniel-d-mais/

ebookmeta.com

The Art of Reinforcement Learning: Fundamentals,


Mathematics, and Implementations with Python 1st Edition
Michael Hu
https://ebookmeta.com/product/the-art-of-reinforcement-learning-
fundamentals-mathematics-and-implementations-with-python-1st-edition-
michael-hu-2/
ebookmeta.com
Introduction to Nursing Research: Incorporating Evidence-
Based Practice 6th Edition Carol Boswell

https://ebookmeta.com/product/introduction-to-nursing-research-
incorporating-evidence-based-practice-6th-edition-carol-boswell/

ebookmeta.com
MEAP Edition
Manning Early Access Program
Optimization Algorithms
AI techniques for design, planning, and control problems

Version 2

Copyright 2023 Manning Publications

For more information on this and other Manning titles go to


manning.com

©Manning Publications Co. To comment go to liveBook


welcome
Thanks for purchasing the MEAP for Optimization Algorithms: AI techniques for design,
planning, and control problems.

Optimization problems are ubiquitous in different aspects of life. This book is written for
practitioners interested in solving ill-structured search and optimization problems using modern
derivative-free algorithms. This book will get you up to speed with the core concepts of search
and optimization and endow you with the ability to deal with practical design, planning and
control problems.

Without assuming any prior knowledge of search and optimization and with an intermediate
knowledge of data structures and Python, this book has been written to take most anyone from
never solving search and optimization problems to being a well-rounded search and optimization
practitioner able to select, implement and adapt the right solver for the right problem.

This book grew out of several courses related to search and optimization taught by me at
different universities and training centers in industry. My 25 years working as an AI and Robotics
professor in the academia and as a technical leader in industry have given me a wealth of
experiences to share with you through this book.
By the end of the book, you should understand:

• How to deal with discrete and continuous ill-structured optimization problems using
deterministic and stochastic derivative-free search and optimization techniques
• How to apply deterministic graph search algorithms to solve graph problems
• How to apply nature-inspired algorithms to find optimal or near-optimal solutions for
practical design, planning and control problems
• How to use machine learning methods to solve search and optimization problems

• How to solve the search dilemma by achieving trade-off between search space exploration
and exploitation using algorithm parameter adaptation
• How to use state-of-the-art Python libraries related to search and optimization

©Manning Publications Co. To comment go to liveBook


The book is divided into five parts. Part 1 covers deterministic graph search algorithms. Part
2 will focus on trajectory-based optimization algorithms giving simulated annealing and tabu
search as examples. Moving forward, Part 3 introduces evolutionary computing algorithms
followed by presenting swarm-intelligence algorithms in Part 4. The last part of the book shows
how machine learning-based methods can be used to solve complex search and optimization
problems. Throughout this book, a wealth of examples and in-depth case studies are provided
for both novices and experts.

I do believe that learning is the common ground between the author and the reader. I hope
that what you’ll get access to will be of immediate use to you. I also look forward to learning
from your valuable feedback to develop the best book possible. Please let me know your
thoughts in the liveBook Discussion forum on what’s been written so far and what you’d like to
see in the rest of the book.

Thanks again for your interest and for purchasing the MEAP!

—Dr. Alaa Khamis

©Manning Publications Co. To comment go to liveBook


brief contents
1 Introduction to Search and Optimization
PART 1: DETERMINISTIC SEARCH ALGORITHMS
2 A Deeper Look at Search and Optimization
3 Blind Search Algorithms
4 Informed Search Algorithms
PART 2: TRAJECTORY-BASED ALGORITHMS
5 Simulated Annealing
6 Tabu Search
PART 3: EVOLUTIONARY COMPUTING ALGORITHMS
7 Simple Genetic Algorithm
8 Genetic Algorithm Variants
PART 4: SWARM INTELLIGENCE ALGORITHMS
9 Particle Swarm Optimization
10 Ant Colony Optimization
PART 5: MACHINE LEARNING-BASED METHODS
11 Introduction to Machine Learning
12 Machine Learning for Search and Optimization
APPENDIXES
A Search and Optimization Libraries in Python
B Benchmarks and Datasets

©Manning Publications Co. To comment go to liveBook


C Solutions to Exercises

©Manning Publications Co. To comment go to liveBook


1

Introduction to Search and


Optimization

This chapter covers

• What are search and optimization?


• Why care about search and optimization?
• Going from "toy problems" to real-world solutions
• Defining an optimization problem
• Introducing well-structured problems and ill-structured problems
• Search algorithms and the search dilemma
As human beings, we constantly strive to optimize our everyday lives. Whether it's getting to
work faster (so you can sleep in a little bit longer), balancing school and leisure time, or even
budgeting for personal spending, we try to maximize the benefits and minimize the costs.
Likewise, corporations maximize profits by increasing efficiency and eliminating waste. For
example, logistics giants like FedEx, UPS, and Amazon spend millions of dollars each year
researching new ways to trim the cost of delivering packages. Similarly, telecommunications
agencies seek to determine the optimal placement of crucial infrastructure, like cellular
towers, to service the maximum number of customers while investing in the minimum level
of equipment.
This sort of optimization behavior is not unique to humans; nature likewise tends towards
efficiency and optimality. Bacterial colonies, comprised of clusters of between 10 million and
10 billion individual organisms, form an adaptable, complex system that can perform many
complicated tasks such as foraging, pathfinding, and learning based on external stimuli.
Insects like ants and honeybees have developed their own unique optimization methods,
from navigating the shortest path to an existing food source to discovering new food sources

©Manning Publications Co. To comment go to liveBook


2

in an unknown external environment. Honeybee colonies focus their foraging efforts on only
the most profitable patches and build their honeycombs with a shape that economizes labor
and wax. Fish swimming in schools or cruising in the same direction minimize total energy
usage by exploiting pressure fields created by the other fish. At the same time, migratory
birds utilize separation, alignment, and cohesion-based optimization to avoid mid-air
collisions and increase flight endurance. Non-biological phenomena also tend towards
efficiency. For example, light traveling between two different media will refract along an
angle that minimizes the travel time.
As technology has developed, computer-based optimization is now an inescapable reality
of the digital era. Transportation network companies (TNCs) like Uber, Lyft, and DiDi route
drivers efficiently during passenger trips and direct drivers to ride-hailing hotspots during idle
periods to minimize passenger wait time. As urbanization intensifies worldwide, local
emergency services depend on efficient dispatching and routing platforms to select and route
the appropriate vehicles, equipment, and personnel to respond to incidents across
increasingly complex metropolitan road networks. Airliners need to solve several optimization
problems such as flight planning, fleet assignment, crew scheduling, aircraft routing and
aircraft maintenance planning. Healthcare systems also handle optimization problems such
as hospital resource planning, emergency procedure management, patient admission
scheduling, surgery scheduling and pandemic containment. Industry 4.0, a major customer
of optimization technology, deals with complex optimization problems such as smart
scheduling/rescheduling, assembly line balancing, supply-chain optimization, and operational
efficiency. Smart cities deal with large-scale optimization problems such as stationary asset
optimal assignments, mobile asset deployment, energy optimization, water control, pollution
reduction, waste management and bushfire containment. These examples show how
ubiquitous and important optimization is as a way to maximize operational efficiency in
different domains.

1.1 Why care about search and optimization?


Search is the systematic examination of states, starting from an initial state, and ending
(hopefully) at the goal state. Optimization techniques are in reality search methods, where
the goal is to find an optimal or a near-optimal state within the feasible search space. The
feasible search space is a subset of the optimization problem space where all the problem's
constraints are satisfied. It's hard to come up with a single industry that doesn't already use
some form of search or optimization methods, software, or algorithms. It's highly likely that
somehow in your workplace or industry, you deal with optimization daily; it's just that you
aren't aware of it. While search and optimization are undoubtedly ubiquitous in almost all
industries, it may not always be practical to use complicated algorithms to optimize
processes. For example, consider a small pizzeria that offers a food delivery service to its
local customers. Let's assume that the restaurant processes around ten deliveries on an
average weeknight. While efficiency-improving strategies (such as avoiding left turns in left-
driving countries or right turns in right-driving countries, avoiding major intersections,
avoiding school zones during drop-off and pick-up times, avoiding bridges during lift times
and favoring downhill roads) may theoretically shorten delivery times and reduce costs, the

©Manning Publications Co. To comment go to liveBook


3

scale of the problem is so tiny that implementing these kinds of changes may not lead to
noticeable impact.
In larger scale problems such as fleet assignment and dispatching, multi-criteria
stochastic vehicle routing, resource allocation, crew scheduling, applying search and
optimization techniques to a problem must be a qualified decision. Some firms or industries
may not benefit from excessive process changes due to a lack of expertise or resources to
implement those changes. There may also be the concern of a potential lack of follow-
through from stakeholders. Implementing the changes could also cost more than the savings
obtained through the optimization process. Later in this book, we will see how these costs
can be accounted for when developing search and optimization algorithms.
Without assuming any prior knowledge of search and optimization and with an
intermediate knowledge of data structures and Python, this book has been written to take
most anyone from never solving search and optimization problems to being a well-rounded
search and optimization practitioner able to select, implement and adapt the right solver for
the right problem. For managers or professionals involved in the high-level technological
decisions at their workplace, these skills can be critical in understanding software-based
approaches, their opportunities, and limitations when discussing process improvement. In
contrast, IT professionals will find these skills more directly applicable when considering
options for developing or selecting new software suites and technologies for in-house use.
The following subsection describes the methodology we will follow throughout this book.

1.2 Going from toy problem to the real world


When discussing algorithms, many books and references will often present them as a formal
definition and then apply them to so-called "toy problems." These trivial problems are helpful
because they often deal with smaller datasets and search spaces while being solvable by
hand iteration. This book seeks to follow a similar approach but takes it one step further by
presenting real-world data implementations. Whenever possible, resources such as real-
world datasets and values are used to illustrate the direct applicability and practical
drawbacks of the algorithms discussed. Initially, the scaled-down toy problems help the
reader appreciate the step-by-step operations involved in the various algorithms. Later, the
real-world Python implementations teach the reader how to use multiple datasets and Python
libraries to address the increased complexity and scope of actual data.
As illustrated in Figure 1.1, source of inspiration of each search or optimization algorithm
is highlighted followed by presenting the algorithm pseudocode, algorithm parameters and
heuristics used. Algorithm pros and cons and adaptation methods are then described. The
book contains many examples that allow the learners to fully understand how each algorithm
works by carrying out iterations by hand on a scaled-down version of the problem. It also
includes many programming exercises in a special problem/solution/discussion format to
understand how a scaled-up version of the problem previously solved by hand can be solved
using Python. Through programming, learners can optimally tune the algorithm and study its
performance and scalability.

©Manning Publications Co. To comment go to liveBook


4

Figure 1.1 Book methodology. Each algorithm will be introduced following a structure that goes from
explanation to application.

Throughout this book, several classical and real-world optimization problems are
considered to show how to use search and optimization algorithms discussed in the book.
Figure 1.2 shows examples of these optimization/search problems.
Real-world design problems or strategic functions deal with situations when time is not as
important as the quality of the solution and users are willing to wait (sometimes even a few
days) to get optimal solutions. Planning problems or tactical functions need to be solved in a
time span between a few seconds to a few minutes. While control problems or operational
functions need to be solved repetitively and quickly, in a time span between few milliseconds
to a few seconds. In order to find a solution during such a short period of time, optimality is
usually traded in for speed gains. In the next chapter, more thorough discussion of these
problem types is provided.

©Manning Publications Co. To comment go to liveBook


5

Figure 1.2 Examples of classical optimization and real-world optimization/search problems.

It is highly recommended that you first perform the necessary hand iterations for the
examples following each algorithm and then try to recreate the Python implementations
yourself. Feel free to play around with the parameters and problem scale in the code; one of
the advantages of running optimization algorithms through software is the ability to tune for
optimality.

1.3 Basic ingredients of optimization problems


Optimization refers to the practice of finding the “best” solutions to a given problem, where
“best” usually means satisfactory or acceptable, possibly subject to a given set of
constraints. The solutions can be classified into feasible, optimal, and near-optimal solutions.
• Feasible solutions are solutions that satisfy all the given constraints.
• Optimal solutions are both feasible and provide the best objective function value
• Near-optimal solutions are feasible solutions that provide a superior objective
function value but are not necessarily the best.
A global optimum, or a global minimum in case of minimization problems, is the best of a
set of candidate solutions. A search space may combine multiple global minima, strong local
minima, and weak local minima as illustrated in Figure 1.3.

©Manning Publications Co. To comment go to liveBook


6

Figure 1.3 Feasible/acceptable solutions fall within the constraints of the problem. Search spaces may display
a combination of global, strong local, and weak local minima.

These optimum seeking methods, also known as optimization techniques, are generally
studied as a part of operations research (OR). OR, also referred to as decision or
management science, is a field that originated at the beginning of World War II due to the
urgent need for assignment of scarce resources in military operations. It is a branch of
mathematics concerned with applying advanced scientific analytical methods to decision-
making and management problems to find the best or optimal solutions.
Optimization problems can generally be stated as follows:
Find X which optimizes ƒ
Subject to a possible set of equality and inequality constraints:

gi(X)= 0, i=1,2,…,m
hj(X)<=0, j=1,2,…,p

Equation 1.1

©Manning Publications Co. To comment go to liveBook


7

where
• X=(x1, x2,…,xn)T is the vector representing the decision variables
• ƒ(X)=(ƒ1(X), ƒ2(X),…, ƒM(X)) is the vector of objectives to be optimized
• gi(X) is a set of equality constraints
• hj(X) is a set of inequality constraints
The following subsections describe three main components of optimization problems:
decision variables, objective functions, and constraints.

1.3.1 Decision Variables


Decision variables represents a set of unknowns or variables that affect the objective
function's value. If X represents the unknowns, also referred to as the independent variables,
then f(X) quantifies the quality of the candidate solution or feasible solution.
Example: Assume that an event organizer is planning a conference on Search and
Optimization Algorithms. The organizer plans to pay a for fixed costs (venue rental, security,
and guest speaking fees) and b for variable costs (pamphlet, lanyard, ID badge, catered
lunch) that depend on the number of participants. Based on past conferences, the organizer
predicts that demand for tickets will be as follows:

Q=5,000-20x

Equation 1.2

Where x is the ticket price and Q is the expected number of tickets to be sold. Thus, the
company expects the following scenarios:
• if the company charges nothing or x=0, the company will give away 5,000 tickets for
free;
• If the ticket price is x=$250, the company will get no attendees as the expected
number of tickets to be sold will be zero and
• If the ticket price x<$250, the company will sell some number of tickets
0<=Q<=5,000.
The profit f(x) the event organizer can expect to earn can be calculated according to the
following:

Profit=Revenue-Costs

Equation 1.3

where Revenue=Qx and costs=a+Qb. Altogether, the profit (or objective) function looks
like this:

f(x)=-20x2+ (5,000+20b)x -5,000b-a, xLB<=x<=xUB

Equation 1.4

©Manning Publications Co. To comment go to liveBook


8

In this problem, there is a single decision variable x, which is the price of the ticket. The
predefined parameters include fixed costs a and variable costs b. The ticket price lower
bound xLB and upper bound xUB are considered boundary constraints. Solving this
optimization problem focuses on finding the best value of x that maximizes the profit ƒ(x).

1.3.2 Objective Functions


An objective function ƒ(x), also known as the criterion or merit function or utility function or
cost function, stands for the quantity to be optimized. Without loss of generality,
optimization can be interpreted as the minimization of a value since the maximization of a
primal function ƒ(x) can be just the minimization of a dual problem generated after applying
mathematical operations on ƒ(x). This means that if the primal is a minimization problem
then the dual is a maximization problem (and vice versa). According to this duality aspect of
optimization problems, a solution x’ which is the minimum for the primal minimization
problem is also, at the same time, the maximum for the dual maximization problem as
illustrated in Figure 1.4. Moreover, simple mathematical operations like addition, subtraction,
multiplication, or division do not change the value of the optimal point. For example,
multiplying or divide ƒ(x) by a positive constant c or adding or subtracting a positive
constant c to or from ƒ(x) does not change the optimal value of the decision variable as
illustrated in Figure 1.4.

©Manning Publications Co. To comment go to liveBook


9

Figure 1.4 Duality principle and mathematical operations on an optimization problem.

Example: In the earlier ticket pricing problem, assume that: a=50,000, b=60, xLB =0 and
xUB=250. Using these values, we have a profit function: ƒ(x)=-20x2+6,200x-350,000.
Following derivative-based approach, we can simply derive the function to find its maximum:
dƒ/dx=-40x+6,200=0 or 40x=6,200. Thus, the optimal number of tickets to sell is 155,
which yields a net profit of $130,500 as shown in Figure 1.5.

©Manning Publications Co. To comment go to liveBook


Random documents with unrelated
content Scribd suggests to you:
music entirely from the formal division of the bar line placed at
regular intervals. Not that these composers dispense with the bar
line completely, but they place it in such disconcertingly irregular
places that the conductor’s task is doubly difficult even when he
attempts to indicate it merely with a single down-beat.
The two following examples from Igor Stravinsky’s
“Petrouchka”[3] illustrate this difficulty. The tempo is too fast to permit
the use of regularly divided gestures, and yet it is very difficult to
bring in the single beats with such metronomic precision that the
musicians can play all of the individual eighth notes evenly and
without hurrying.
[3] Copyright by Russischer Musikverlag, Berlin

EXAMPLE Nᵒ. 1
3 in a measure

[Listen]
EXAMPLE Nᵒ. 2
[Listen]

The author, in his conducting class at New York University has


experimented with several methods, and has finally hit upon the
following system of teaching the intricate baton technic involved in
the conducting of works like Stravinsky’s “Petrouchka.”
The student is made to sit at the piano and play simple five finger
figures with a single accent on the first note which is always played
by the thumb.
[Listen] [Listen]

[Listen]

[Listen] [Listen]
[Listen]

[Listen]

Playing the eighth notes in a rather quick tempo each exercise is


to be repeated until the feeling of the recurrence of the down-beat
(which corresponds to the accented thumb stroke) becomes entirely
automatic. Care must be taken never to vary the speed of the eighth
notes and to accent only the first note.
Translated into terms of this exercise the two examples from
“Petrouchka” would be as follows:
[Listen]

[Listen]
The speed of the eighth notes must never vary.

Fractional or uneven time


[Listen]
Beat 3-in-a-measure, merely making the third beat one-eighth
note longer.

[Listen]
Beat 2-in-a-measure, merely making the second beat one-eighth
note longer.

[Listen]
The Hymn of Jesus:—Gustave Holst (Copyright 1920 by Stainer
and Bell, London)
[Listen]
Beat 4-in-a-measure, merely making the fourth beat one-eighth
note longer.

ON THE CONDUCTING OF WALTZES


To begin with, a dividing line must be drawn between a waltz
played for dancing and the concert waltz. The former is performed in
a regular rhythmic manner everywhere, except in Vienna and South
America, where the dancers are accustomed to little freedoms of
tempo. There is so much really good music written in this form, that it
is a pity to hear waltzes “ground out” in the reprehensible one-beat-
in-a-measure style of so many of our Military Bandmasters. Portions
of Strauss’ “Artist’s Life” Waltzes are given in the following examples,
which also contain various modes of beating waltz time to conform
with the spirit of the music.
There are many ways of conducting waltz time. Some conductors
beat all the beats, others again, only one beat to the measure.
Analysis of some of the methods of the great conductors who have
not disdained to play the waltzes of composers like Waldteufel or
Johann Strauss, has lead us to believe that the three styles of
conducting explained in the following diagrams are the ones most
generally used.
A—The one-beat-in-a-measure style for passages of flowing
melody and great verve.
In order to avoid a monotony of motion, it is best to start the
down-beats of each measure, alternately from the left and the right.
The dotted line in the diagram indicates the reflex or rebound
movement, which brings the hand and arm in a position to start the
next beat.

DIAGRAM Nᵒ.1 (Style 1)


(A) Starting the beat from left to right.

(B) Starting the beat from the right.

B—Following the heavy down-beat of the measure, the second


beat will be indicated by a sharp sideward wrist movement and in
lieu of the third beat, the hand and arm will be drawn up to the
original position in a more relaxed manner.

DIAGRAM Nᵒ. 2 (Style 2)

Light and delicate rhythmic figures are best indicated by this


method.
C—The third method is the regular gesture used in any 3/4 or 3/8
time and indicates each beat.

DIAGRAM Nᵒ. 3 (Style 3)


Same as 3/4 time.

In the following extract from Artists’ Life Waltz by Strauss, the


three different styles are applied. The various strains and the manner
of beating each measure, are indicated by the Roman Numerals
which correspond to the diagrams.

I Diagram 1
II Diagram 2
III Diagram 3
[Listen]

From Hector Berlioz’


“Treatise on Conducting”
A dilemma sometimes presents itself when certain parts—for the
sake of contrast—are given a triple rhythm, while others preserve the
dual rhythm.

[Listen]

If the wind-instrument parts in the above example are confided to


players who are good musicians, there will be no need to change the
manner of marking the bar, and the conductor may continue to
subdivide it by six, or to divide it simply by two. The majority of
players, however, seeming to hesitate at the moment when, by

You might also like