0% found this document useful (0 votes)
4 views

Optimization Algorithms (MEAP V02) Alaa Khamis download

The document is an introduction to the book 'Optimization Algorithms' by Alaa Khamis, which focuses on AI techniques for solving design, planning, and control problems through various optimization methods. It aims to equip readers with the knowledge to tackle both discrete and continuous optimization problems using modern algorithms, without requiring prior knowledge in the field. The book is structured into five parts covering deterministic search algorithms, trajectory-based algorithms, evolutionary computing, swarm intelligence, and machine learning methods, along with practical examples and case studies.

Uploaded by

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

Optimization Algorithms (MEAP V02) Alaa Khamis download

The document is an introduction to the book 'Optimization Algorithms' by Alaa Khamis, which focuses on AI techniques for solving design, planning, and control problems through various optimization methods. It aims to equip readers with the knowledge to tackle both discrete and continuous optimization problems using modern algorithms, without requiring prior knowledge in the field. The book is structured into five parts covering deterministic search algorithms, trajectory-based algorithms, evolutionary computing, swarm intelligence, and machine learning methods, along with practical examples and case studies.

Uploaded by

edinzianka
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/ 75

Optimization Algorithms (MEAP V02) Alaa Khamis

install download

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

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

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/

Algorithms for Convex Optimization 1st Edition Vishnoi

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

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/

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/
Understanding the New Proxy Wars 1st Edition Peter
Bergen

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

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/

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/

Quick Compendium of Clinical Pathology 4th Edition


Daniel D. Mais

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

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/
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/
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


10

Figure 1.5 Ticket pricing problem. The optimal pricing which maximizes profits is $155 per ticket.

In ticket pricing problem, we have a single objective function to be optimized, which is


the profit. In this case, the problem is called mono-objective optimization problem. An
optimization problem involving multiple objective functions is known as a multi-objective
optimization problem. For example, assume that we want to design an electric vehicle (EV).
This design problem’s objective functions can be minimizing acceleration time and
maximizing EPA driving range. The acceleration time is the time in seconds the EV takes to
accelerate from 0 to 60 mph. EPA range is the approximate number of miles that a vehicle
can travel in combined city and highway driving (using a mix of 55% highway and 45% city
driving) before needing to be recharged according to the Environmental Protection Agency
(EPA)'s testing methodology. Decision variables can include the size of the wheel, the power
of the electric motor, and the battery's capacity. A bigger battery is needed to extend the
driving range of the EV, which adds extra weight, and therefore the acceleration time
increases. In this example, the two objectives are conflicting as we need to minimize
acceleration time and maximize the EPA range as shown in Figure 1.6.

©Manning Publications Co. To comment go to liveBook


11

Figure 1.6 Electric vehicle design problem for maximizing EPA range and minimizing acceleration time.

This multi-objective optimization problem can be handled using a preference-based multi-


objective optimization procedure or by using a Pareto optimization approach. In the former
approach, duality principle is applied first to transform all the conflicting objectives for
maximization (e.g., maximizing the EPA range and the inverse of the acceleration time) or
minimization (e.g., minimizing the acceleration time and the inverse of the EPA range) and
then combine these multiple objectives into a single or overall objective function by using a
relative preference vector or a weighting scheme to scalarize the multiple objectives. For
example, you may give more weight for EPA range over the acceleration time. However,
finding this preference vector or weights is subjective and sometimes is not straightforward.
The latter approach relies on finding multiple trade-off optimal solutions and chooses one
using higher-level information. This procedure tries to find the best tradeoff by reducing the
number of alternatives to an optimal set of non-dominated solutions known as the Pareto
Frontier, which can be used to take strategic decisions in multi-objective space. Multi-
objective optimization will be discussed in later chapters.
Constraint-satisfaction problems (CSP) do not define an explicit objective function.
Instead, the goal is to find a solution that satisfies a given set of constraints. The N-queen
problem is an example of CSP. In this problem, the aim is to put n queens on an n x n board
with no two queens on the same row, column, or diagonal. This 4x4 Queen CSP problem has

©Manning Publications Co. To comment go to liveBook


12

256 possible solutions (44) and two optimal solutions. Neither of the two optimal solutions is
inherently or objectively better than the other. The only requirement of the problem is to
satisfy the given constraints.

1.3.3 Constraints
Constrained optimization problems have a set of equality and/or inequality constraints gi(X),
lj(X) that restrict the values assigned to the unknowns. In addition, most problems have a
set of boundary constraints, which define the domain of values for each variable.
Furthermore, constraints can be hard (must be satisfied) or soft (desirable to satisfy).
Consider the following examples from a school timetabling problem:
• Not having multiple lectures in the same room at the same time is a hard constraint
• Not having a teacher give multiple lectures at the same time is also a hard
constraint
• Guaranteeing a minimum of three teaching days for every teacher may be a soft
constraint
• Locating back-to-back lectures in nearby rooms may be a soft constraint
• Avoiding scheduling very early or very late lectures may also be a soft constraint
As another example of hard and soft constraints, navigation apps such as Google Maps,
Apple Maps, Waze, or HERE WeGo may allow users to set preferences for routing.
• Avoiding ferries, toll roads, and highways would be hard constraints
• Avoiding busy intersections, highways during rush hour, or school zones during drop-
off and pick-up times might be soft constraints
Soft constraints can be modeled by incorporating a reward/penalty function as part of the
objective function. The function rewards solutions that satisfy the soft constraints and
penalize those that do not.
Example: Assume that there are 10 parcels to be loaded in the cargo bike from Figure
1.7. Each parcel has its own weight, profit, and efficiency value (profit per kg). The goal is to
select the parcels to be loaded in such a way that the utility function ƒ1 is maximized and the
weight function ƒ2 is minimized. This is a classic example of a combinatorial problem.

𝑓𝑓1 = ∑𝑛𝑛𝑖𝑖=0 𝐸𝐸𝑖𝑖

Equation 1.5

where n is the total number of packages and Ei is the efficiency of package i

𝑛𝑛 𝑛𝑛

𝑓𝑓2 = �� 𝑤𝑤𝑖𝑖 − 𝐶𝐶 � , 50 is added 𝑖𝑖𝑓𝑓𝑓𝑓 �� 𝑤𝑤𝑖𝑖 > 𝐶𝐶�


𝑖𝑖=0 𝑖𝑖=0

Equation 1.6

©Manning Publications Co. To comment go to liveBook


13

where ωi is the weight of package i and C is the maximum capacity of the bike. A penalty of
50 is added if and only if the total weight of the added parcels exceeds the maximum
capacity.

Figure 1.7 The cargo bike loading problem is an example of a problem with a soft constraint. While the weight
of the packages can exceed the bike’s capacity, a penalty will be applied when the bike is overweight.

Soft constraints can also be used to make the search algorithm more adaptive. For
example, the severity of the penalty can be dynamically changed as the algorithm
progresses, imposing less strict penalties at first to encourage exploration, while becoming
more severe near the end to generate a result largely bound by the constraint.

1.4 Well-structured problems vs. Ill-structured problems


We can further classify optimization problems based on their structure, and the procedure
that exists (or doesn’t exist) for solving them. The following subsections introduced well-
structured and ill-structured problems.

1.4.1 Well-structured problems (WSP)


In “The Structure of Ill Structured Problems” (Artificial Intelligence, 1973), Herbert Simon
describes the six main characteristics of WSPs:
• There is a definite criterion for testing any proposed solution and a mechanizable
process for applying the criterion.
• There is at least one problem space in which the initial problem state, the goal state,
and all other states that may be reached, or considered, in the course of attempting a
solution of the problem can be represented.
• Attainable state changes (legal moves) can be represented in a problem space, as
transitions from given states to the states directly attainable from them. But
considerable moves, whether legal or not, can also be represented—that is, all
transitions from one considerable state to another.

©Manning Publications Co. To comment go to liveBook


14

• Any knowledge that the problem solver can acquire about the problem can be
represented in one or more problem spaces.
• If the actual problem involves acting upon the external world, then the definition of
state changes and of the effects upon the state of applying any operator reflects with
complete accuracy in one or more problem spaces the laws (laws of nature) that
govern the external world.
• All these conditions hold in the strong sense that the basic processes postulated
require only practicable amounts of computation and the information postulated is
effectively available to the processes—that is, available with the help of only
practicable amounts of search.
Assume that we are planning a robotic pick-and-place task in an inspection system. In
this scenario, the robot waits until receiving a signal from a presence sensor, which indicates
the existence of a defected workpiece over the conveyer belt. The robot stops the conveyer
belt and picks the defected piece and deposits it in a waste box. The robot reactivates the
movement of the conveyer belt after depositing the defected piece. After the operation, the
robot returns to its initial position and the cycle repeats itself again. As illustrated in Figure
1.8, this problem has the following well-structured components:
• Feasible States: position and speed of the robot arm and orientation and status
(open or close and orientation) of its end-effector (gripper)
• Operator (successor): robot arm motion control command to move from one point
to another following a certain singularity-free trajectory (positions or joint angles in
space and motion speed) and end-effector control (orientation and open or close).
• Goal: pick and place a defected workpiece regardless its orientation
• Solution/Path: optimal sequence through state space for fastest pick-and-place
operation
• Stopping Criteria: defected workpiece is picked from the conveyer belt and is placed
in the waste box and robot returns to home position
• Evaluation Criteria: pick-and-place duration and/or success rate of pick-and-place
process.

©Manning Publications Co. To comment go to liveBook


15

Figure 1.8 A well-structured problem will have a defined problem space, operators, and evaluation criteria.

As you can see, the work environment is highly structured, static and fully observable. An
optimal pick-and-place plan can be generated and executed with high level of certainty. This
pick-and-place problem can be considered as WSP.

1.4.2 Ill-structured Problems (ISP)


Ill-structured problems (ISPs) are complex discrete/continuous problems without algorithmic
solutions/general problem solvers. Ill-structured problems are characterized by one or more
of the following characteristics:
• Problem space with different views of problems, unclear goal, multimodality, and
dynamic nature.
• Lack of exact differentiable mathematical models and/or well-proven algorithmic
solutions
• Solutions are contradictory, consequence difficult to predict and risk difficult or
impossible to calculate resulting in lack of clear evaluation criteria
• Considerable data imperfection in terms of uncertainty, partial observability,
vagueness, incomplete information, ambiguity and/or unpredictability makes
monitoring the execution of the solutions difficult and sometimes impossible.
• Computational intractability
Example: Assume that we need to find the optimal dispatching of four elevators to serve
users between ten floors as illustrated in Figure 1.9. This is a classic example of a problem
too large to solve using traditional means.

©Manning Publications Co. To comment go to liveBook


16

Figure 1.9 Elevator dispatching problem. With four elevator cars and ten floors, this problem has 1022 possible
states.

In this problem, the following objective functions can be considered in this optimal
dispatching problem:
• Minimizing the average waiting time: how long the user waits before getting on an
elevator
• Minimizing the average system time: how long the user waits before being dropped
off at the destination floor
• Minimizing the percentage of the users whose waiting time exceeds 60 seconds.
• Ensuring fairness in serving all the users of the elevators.
This optimal dispatching problem is an example of ISP as the problem space has a
dynamic nature and partial observability; it is impossible to predict the user calls and
destinations. Moreover, the search space is huge due to the extremely high number of
possible states. There are 1022 possible states:
• 218 possible combinations of the 18 hall call buttons, i.e., up, and down buttons, at
each floor except the first and the last floor.
• 240 possible combinations of the 40 elevator buttons if each elevator has 10 buttons.
• 184 possible combinations of the position and directions of the elevators.
The total number of states for a problem as simple as dispatching this small building’s
elevators is more than the number of stars in the universe!

©Manning Publications Co. To comment go to liveBook


17

1.4.3 WSP but practically ISP


The Traveling Salesman Problem (TSP) is an example of a problem that may be well-
structured in principle, but in practice becomes ill-structured. This is because of the
impractical amount of computational power required to solve this problem in real-time.
Example: Assume that there is a traveling salesman assigned to visit a list of n cities.
The salesman would like to make sales calls to all these cities in the minimum amount of
time, as salespeople are generally paid by commission rather than hourly. Furthermore, the
tour of the cities may be asymmetric; the time it takes to go from city A to city B may not be
the same as the reverse, due to infrastructure, traffic patterns, and one-way streets. For
example, with 13 cities to visit, the problem may seem trivial at first. However, upon closer
examination it is revealed that the search space for this TSP results in 13!=6,227,020,800
different possible routes to be examined in case of using naive algorithms! However,
dynamic programming algorithms enable reduced complexity as we will see in the next
chapter.
This book largely focuses on ISPs and WSPs but practically ISPs kinds of problems, for a
few reasons:
• Well-structured problems tend to have well-known solving algorithms that often
provide a trivial, step-by-step procedure for solving WSPs. As such, there often
already exist very efficient and well-known solutions to these kinds of problems.
Moreover, several WSPs can be also solved using derivative-based generic solvers.
• The amount of computational power needed to solve well-structured problems is often
negligible or very manageable at worst. Especially with the continued improvement of
consumer-grade computers, not to mention the vast resources available through
cloud computing and distributed processing, well-structured problems often do not
have to settle for “near-optimal” solutions due to computational bottlenecks.
• Most problems in the real world are ill-structured problems, as the problem scope,
state, and environment are dynamic and partially observable with certain degrees of
uncertainties. Solutions or algorithms for ill-structured problems therefore have much
more applicability to real-world scenarios, and there is a greater incentive to finding
solutions to these problems.
Most of the algorithms explored in this book are derivative-free and stochastic; they use
randomness in their parameters and decision processes. These are often well-suited to
solving ill-structured problems, as the randomness of their initial states and operators allow
the algorithms to escape local minima and find optimal or near-optimal solutions. On the
other hand, deterministic algorithms use well-defined and procedural paths to reach
solutions, and generally are not well suited for ISPs as they either cannot work in unknown
search spaces or are unable to return solutions in a reasonable amount of time.

1.5 Search Algorithms and the Search Dilemma


The goal of any optimization method is to assign values to decision variables so that the
objective function is optimized. To achieve this, optimization algorithms search the solution
space for candidate solutions. Constraints are simply limitations on specific regions in the

©Manning Publications Co. To comment go to liveBook


18

search space. Thus, all optimization techniques are in reality just search methods, where the
goal is to find feasible solutions to satisfy constraints and maximizes (or minimizes) the
objective functions. We define “search” as the systematic examination of feasible states,
starting from the initial state, and ending (hopefully) at the goal state. However, while we
explore the feasible search space, the question is if we find a few reasonably good
neighboring solutions, should we exploit this region or should we explore more looking for
better solutions in other regions of the feasible search space?
This exploration-exploitation or diversification-intensification dilemma is one of the most
important problems in search and optimization and in life as well. We apply exploration-
exploitation tactics in our life. When we move to a new city, we start by exploring different
stores and restaurants and then focus on shortlisted options around us. During midlife crisis,
some middle-aged individuals start to feel bored getting stuck in daily routine and lifestyle
without clear satisfactory accomplishment and tend to take more explorative actions. US
immigration system tries to avoid exploiting specific segments of applicants (e.g., family,
skilled-workers, refugees and asylees) and enables more diversity through computer-
generated lottery. In social insects like honeybees, foraging for food sources is performed by
two different worker groups, recruits and scouts (5-25% of the foragers). Recruits focus on a
specific food source while scouts are novelty seekers who keep scouting around for rich
nectar. In search and optimization, exploration-exploitation dilemma represents the tradeoff
between exploring new unvisited states/solutions in the search space and exploiting the elite
solutions found in a certain neighborhood in the search space (Figure 1.10).
Exploration (or diversification) is the process of investigating new regions in the feasible
search space with the hope of finding other promising solutions. On the other hand,
exploitation (or intensification) is the process of directing the search agent to focus on an
attractive region of the search space where good solutions have been already found.

©Manning Publications Co. To comment go to liveBook


19

Figure 1.10 Search Dilemma. There is always a tradeoff between branching out to new areas of the search
space or focusing on an area with known “good” or elite solutions.

Local search algorithms are exploitation/intensification algorithms that can be easily


trapped in local optima if the search landscape is multimodal. On the other extreme, random
search algorithms keep exploring the search space with a high chance of reaching global
optima at the cost of the impractical search time. Generally speaking, explorative algorithms
can find global optima at the cost of processing time, while exploitative algorithms risk
getting stuck at local minima.

©Manning Publications Co. To comment go to liveBook


20

1.6 Summary
• Optimization is a search process for finding the “best” solutions to a problem that
provide the best objective function values, possibly subject to a given set of hard
(must be satisfied) and soft (desirable to satisfy) constraints.
• Ill-structured problems are complex, discrete, or continuous problems without exact
differentiable mathematical models and/or algorithmic solutions or general problem
solvers. They usually have dynamic and/or partially observable large search spaces
that cannot be handled by classical optimization methods.
• Stochastic algorithms are non-greedy algorithms that explicitly use randomness to
find the global optimal or near-optimal solution in a reasonably practical time. In
many real-life applications, quickly finding a near-optimal solution is better than
spending a large amount of time in search for an optimal solution.
• Two key concepts you’ll see frequently in future chapters are
exploration/diversification and exploitation/intensification. Handling this search
dilemma by achieving a trade-off between exploration and exploitation will allow the
algorithm to find optimal or near-optimal solutions without getting trapped in local
optima in an attractive region of the search space and without spending large amount
of time.

©Manning Publications Co. To comment go to liveBook


21

A Deeper Look at Search and


Optimization

This chapter covers

• Classifying optimization problems based on different criteria.


• Classifying search and optimization algorithms based on the way the search space is
explored and how deterministic the algorithm is.
• Introducing heuristics, meta-heuristics, and heuristic search strategies.
• A first look at nature-inspired search and optimization algorithms.
Before we dive into the problems and algorithms that we hinted at in Chapter 1, it useful to
first understand how we “talk” about these problems and algorithms. Classifying a problem
allows us to group similar problems together, and potentially exploit already-existing
solutions. For example, a Travelling Salesman Problem(TSP) problem involving geographic
values (i.e., cities and roads) may be used as a model to find the minimum length of the
wires connecting the pins in very large-scale integration (VLSI) design. The same can be said
for classifying the algorithms themselves, as grouping algorithms with similar properties
allows us to easily identify the right algorithm to solve the problem and meeting expectation
in terms of quality of the solution and permissible search time for example. Throughout this
chapter, we discuss common classifications of optimization problems and algorithms.
Heuristics and meta-heuristics are also introduced as general algorithmic framework or high-
level strategies that guide the search process. Many of these strategies are inspired from
nature so we shed some lights on nature inspired algorithms. Let’s start by discussing how
we can classify optimization problems based on different criteria in the first section.

©Manning Publications Co. To comment go to liveBook


22

2.1 Optimization Problem Classification


Optimization is everywhere! In everyday life, you may face different kinds of optimization
problems. For example, you may like to set the AC thermostat at a certain degree to stay
comfortable and at the same time to save energy. You may select light fixtures and adjust
the light level to reduce energy costs. When you start driving your electric vehicle (EV), you
search for the fastest route and/or most energy-efficient route that takes you to your
destination. Before arriving to your destination, you may look for a parking spot that is
affordable and provides shortest walking distance to the destination and offers EV charging
and preferably is underground. These optimization problems have different levels of
complexities that mainly depend on the type of the problem. As mentioned in the previous
chapter, the process of optimization selects decision variables from a given feasible search
space in such a way as to optimize (minimize or maximize) a given objective function, or in
some cases, multiple objective functions. Search and optimization problems are
characterized by three main components, namely, decision variables or design vector,
objective functions or criteria to be optimized, and a set of hard and soft constraints to be
satisfied. The nature of these three components, the permissible time to solve the problem
and the expected quality of the solutions lead to different types of optimization problems, as
shown in Figure 2.1.

©Manning Publications Co. To comment go to liveBook


23

Figure 2.1 Optimization problem classification. An optimization problem can be broken down into its
constituent parts, which form the basis of the classification of such problems.

The following subsections explain these types in greater detail and provide examples for
each type of optimization problem.

2.1.1 Number and Type of Decision Variables


According to the number of decision variables, optimization problems can be broadly grouped
into univariate (single variable) or multivariate problems (multiple decision variables). For
example, vehicle speed, acceleration, and tire pressure are among the parameters that
impact a vehicle’s fuel economy, where fuel economy refers to how far a vehicle can travel
on a specific amount of fuel. According to the US Department of Energy, controlling the
speed and acceleration of a vehicle can improve its fuel economy by 15%–30% at highway
speeds, and 10%–40% in stop-and-go traffic. A study by the National Highway Traffic Safety
Administration (NHTSA) in the USA found that a 1% decrease in tire pressure correlated to a

©Manning Publications Co. To comment go to liveBook


24

0.3% reduction in fuel economy. If we are only looking for the optimal vehicle speed for
maximum fuel economy, the problem is a univariate optimization problem. Finding the
optimal speed and optimal acceleration for maximum fuel economy is a bivariate
optimization problem, while finding optimal speed, acceleration, and tire pressure is a
multivariate problem.
Problem classification also varies according to the type of the decision variables. A
continuous problem involves continuous-valued variables where xj ∈ R. In contrast, if xj ∈ Z,
the problem is an integer, or discrete optimization problem. A mixed-integer problem has
both continuous-valued and integer-valued variables. For example, optimizing elevator speed
and acceleration (continuous variables) and the sequence of picking up passengers (discrete
variable) is a mixed-integer problem. Problems where the solutions are sets, combinations,
or permutations of integer-valued variables are referred to as combinatorial optimization
problems.

©Manning Publications Co. To comment go to liveBook


25

Combination vs. Permutation


Combinatorics is the branch of mathematics studying both combination and permutation of a set of elements. The
main difference between combination and permutation is the order. If the order of the elements doesn’t matter, it is a
combination, and if the order does matter, it is a permutation. Thus, permutations are ordered combinations.
Depending on whether repetition of these elements is allowed or not, we can have different forms of combinations
and permutations as shown in Figure 2.2.

Figure 2.2 Combinations and permutations. Both combinations and permutations have variants with and without
repetition. The difference lies in the fact that permutations respect order and are thus ordered combinations.

For example, assume that we are designing a fitness plan to include multiple fitness activities. Five types of fitness
exercises are available to be included in the fitness plan, namely, jogging, swimming, biking, yoga, and aerobics. In a
weekly plan, if we are to choose only 3 out of these 5 exercises and the repetition is allowed, the number of possible
combinations will be: (n+r-1)!/r!(n-1)! = (5+3-1)!/3!(5-1)! = 7!/(3!×4!) =35. This means that we can generate 35
different fitness plans by selecting 3 out of the available 5 exercises and by allowing repetition.

However, if repetition is not allowed, the number of possible combinations will be: C(n,r)=n!/r!(n-r)!=5!/(3!×2!)=10.
This formula is often called “n choose r” (such as “5 choose 3’) and is also known as the “Binomial Coefficient”. This
means that we can generate only 10 plans if we don’t want to repeat any of the exercises.

In both cases of combination with and without repetition, the fitness plan doesn’t include the order of performing
the included exercises. If we are to respect specific order, the plan in this case will take the form of a permutation. If
repeating exercises is allowed, the number of possible permutations to select 3 exercises out of the 5 available
exercises will be: nr=53=125. However, if repetition is not allowed, the number of possible permutations will be:
P(n,r)=n!/(n-r)!=5!/(5-3)!=60.

Combinatorics can be implemented fairly easily in Python using code from scratch, but there are excellent
resources available in the form of libraries, such as sympy. For example, the Binomial Coefficient can be calculated in
sympy using the following simple code:

from sympy import binomial


print(binomial(5,3))

See Appendix-A and the documentation for sympy for more on implementing combinatorics in Python.

©Manning Publications Co. To comment go to liveBook


26

The Traveling Salesman Problem (TSP) is a common example of combinational problems


whose solution is a permutation, or a sequence of cities to be visited. In TSP, given n cities,
a traveling salesman must visit the n cities and then return home, making a loop (round
trip). The salesman would like to travel in the most efficient way (fastest, cheapest, shortest
distance, or some other criterion). The search space in TSP is very large. For example, let’s
assume the traveling salesman is to visit the 13 major cities in the Greater Toronto Area
(GTA) as illustrated in Figure 2.3.
TSP can be classified into symmetric TSP (STSP) and asymmetric (ATSP). In the STSP,
the distance between two cities is the same in each opposite direction, forming an undirected
graph. This symmetry halves the number of possible solutions. ATSP is a strict generalization
of the symmetric version. In the ATSP, paths may not exist in both directions or the
distances might be different, forming a directed graph. Traffic collisions, one-way streets,
bridges and airfares for cities with different departure and arrival fees are examples of how
this symmetry could break down.

Figure 2.3 TSP in Greater Toronto Area (GTA). The traveling salesman must visit all the 13 cities, and wishes to
select the “best” path, whether that be distance, time, or some other criterion.

The naive solution’s complexity is O(n!). These means that there are n!=13!=
6,227,020,800 possible tours in case of ATSP. This makes both STSP and ATSP, NP-hard
problems. However, dynamic programming (DP) algorithms enable reduced complexity.
Dynamic programming is a method of solving optimization problems by breaking them down
into smaller subproblems and solving each subproblem independently. For example, the
complexity of Bellman-Held-Karp algorithm [1] is of O(2n×n²). Different solvers and
algorithms with different level of computational complexities and approximation ratios such
as Concorde TSP Solver, 2-opt/3-opt algorithm, branch and bound algorithms, Christofides
algorithm or Christofides–Serdyukov algorithm, Bellman–Held–Karp algorithm, Lin-Kernighan
algorithm, metaheuristics-based algorithms, graph neural networks or deep reinforcement
learning methods. For example, Christofides algorithm [2] is a polynomial-time

©Manning Publications Co. To comment go to liveBook


27

approximation algorithm that produces a solution to the TSP that is guaranteed to be no


more than 50% longer than the optimal solution with a time complexity of O(n3). See
Appendix-A for solution of TSP using Christofides algorithm implemented in networkx. We
will discuss how to solve TSP using a number of these algorithms throughout this book.
TSP is used as a platform for the study of general methods that can be applied to a wide
range of discrete optimization problems. These problems include, but are not limited to,
microchips manufacturing, permutation flow shop scheduling, arranging school bus routes to
pick up children in a school district, assignment of routes for airplanes, transportation of
farming equipment, scheduling of service calls, meal delivery, and the routing of trucks for
parcel delivery and pickup. For example, the Capacitated Vehicle Routing Problem (CVRP) is
a generalization of the TSP where one has to serve a set of customers using a fleet of
homogeneous vehicles based at a common depot. Each customer has a certain demand for
goods which are initially located at the depot. The task is to design vehicle routes starting
and ending at the depot such that all customer demands are fulfilled. Later in this book,
several examples are given to show how to solve TSP and its variants using stochastic
approaches.

©Manning Publications Co. To comment go to liveBook


28

Problem Types
Decision problems are commonly classified based on their levels of complexities. These classes can be also applied
to optimization problems given the fact that optimization problems can be converted into decision-making problems.
For example, the optimization problem whose objective is to find an optimal or near-optimal solution within a feasible
search space can be paraphrased as a decision-making problem, which answers the question: “Is there is an optimal
or a near-optimal solution within the feasible search space?” The answer will be {“yes” or “no”} or {“True” or “False”}. A
generally-accepted notion of algorithm's efficiency is that its running time is polynomial. Problems that can be solved
in polynomial time are known as tractable. Figure 2.4 shows different types of problems and gives examples of
commonly used benchmark/toy and real-life application of each type.

Figure 2.4 Problem classes based on hardness and completeness. Problems can be categorized into NP-hard, NP-
complete, NP, or P.

For example, a complexity class P represents all decision problems that can be solved in polynomial time by
deterministic algorithms (i.e., algorithms that do not guess at a solution). The NP or Nondeterministic Polynomial
problems are problems whose solutions are hard to find but easy to verify and are solved by a non-deterministic
algorithm in polynomial time. NP-complete problems are problems that are both NP-hard and verifiable in polynomial
time. Finally, a problem is NP-hard if it is at least as hard as the hardest problem in NP-complete. NP-hard problems
are usually solved by approximation or heuristic solvers as it is hard to find efficient exact algorithms to solve such
kind of problems.

Clustering is an example of combinatorial problems whose solution takes the form of a


combination where the order doesn’t matter. In clustering, given n objects, we need to group
them in k groups (clusters) in such a way that all objects in a single group or cluster have a
“natural”' relation to one another, and objects not in the same group are somehow different.
This means that the objects will be grouped based on some similarity or dissimilarity metric.
The following formula is known as a Stirling number of the second kind (or Stirling partition

©Manning Publications Co. To comment go to liveBook


29

number) and gives the number of ways to partition a set of n objects into k non-empty
subsets:

𝑘𝑘
𝑛𝑛 1 𝑘𝑘
𝑆𝑆(𝑛𝑛, 𝑘𝑘) = � � = �(−1)𝑖𝑖 � � (𝑘𝑘 − 𝑖𝑖)𝑛𝑛
𝑘𝑘 𝑘𝑘! 𝑖𝑖
𝑖𝑖=0

Equation 2.1

Let's consider smart cart clustering as an example. Shopping and luggage carts are
commonly found in shopping malls and large airports. Shoppers or travelers pick up these
carts at designated points and leave them in arbitrary places. It is a considerable task to re-
collect them, and it is therefore beneficial if a “smarter” version of these carts could draw
themselves together automatically to the nearest assembly points as illustrated in Figure 2.5.

Figure 2.5 Smart Cart Clustering. Unused shopping or luggage carts congregate near designated assembly
points to make collection and redistribution easier.

In practice, this problem is considered an NP-hard problem, as the search space can be
very large based on the number of available carts and number of assembly points. In order
to cluster these carts effectively, the centers of clustering (centroids) must be found. The
carts in each cluster will then be directed to the assembly point closest to the centroids. For
example, assume that there are 50 carts to be clustered around 4 assembly points. This
means that n=50 and c=4. Stirling numbers can be generated using the sympy library. To do
so, simply call the stirling function on two numbers n and k.

©Manning Publications Co. To comment go to liveBook


30

from sympy.functions.combinatorial.numbers import stirling


print(stirling(50,4))
print(stirling(100,4))

The number is 5.3×1028 and if n is increased to 100, the number becomes 6.7×1058.
Enumerating all possible partitions for large problems is practically not feasible.

2.1.2 Landscape and Number of Objective Functions


Objective function’s landscape represents the distribution of values of the objective function
in the feasible search space. When you walk over this landscape, you find the optimal
solution or the global minima in the lowest valley of the landscape assuming that you are
dealing with a minimization problem or in the highest peak of the landscape in case of a
maximization problem. According to the landscape of the objective function, if there exists
only one clear global optimal solution, the problem is unimodal (e.g., convex and concave
functions). On the other hand, in a multimodal problem, more than one optimum exists. The
objective function is called deceptive when the global minimum lies in a very narrow valley
and at the same time there exists a strong local minimum with a wide basin of attraction
such that the value of objective function is close to the value of objective function at global
minimum [3]. Figure 2.6 is a 3D visualization of the landscapes of unimodal, multimodal, and
deceptive functions generated using Python generated by Listing 2.1. Complete listing is
available in the GitHub repo of the book.

Listing 2.1 Examples of Objective Functions


import numpy as np
import math
import matplotlib.pyplot as plt

def objective_unimodal(x, y): #A


return x**2.0 + y**2.0

def objective_multimodal(x, y): #B


return np.sin(x) * np.cos(y)

def objective_deceptive(x, y): #C


return (1-(abs((np.sin(math.pi*(x-2))*np.sin(math.pi*(y-2)))/(math.pi*math.pi*(x-2)*(y-
2))))**5)*(2+(x-7)**2+2*(y-7)**2)

#A Unimodal function
#B Multimodal function
#C Deceptive function [3]

©Manning Publications Co. To comment go to liveBook


31

Figure 2.6 Unimodal, multimodal, and deceptive functions. Unimodal functions have one global optimum,
while multimodal functions can have many. Deceptive functions contain false optima close to the value of
objective function at global minimum, which can cause some algorithms to get stuck.

If the quantity to be optimized is expressed using only one objective function, the
problem is referred to as a mono-objective or single-objective optimization problem (such as
convex or concave functions). A multi-objective problem specifies multiple objectives to be
simultaneously optimized. Problems without an explicit objective function are called
Constraint-Satisfaction Problems (CSP). The goal in this case is to find a solution that
satisfies a given set of constraints. The N-queen problem is an example of CSP. In this
problem, the aim is to put n queens on an n×n board with no two queens on the same row,
column, or diagonal, as illustrated in Figure 2.7. In this 4-queen problem, there are 5
conflicts in the first state ({Q1,Q2}, {Q1,Q3},{Q2,Q3},{Q2,Q4} and {Q3,Q4}). After
moving Q4, the number of conflicts reduces by 2 and after moving Q3, the number of
conflicts is only 1, which is between Q1 and Q2.

Figure 2.7 N-Queen Problem. This problem has no objective function, rather, only a set of constraints that
must be satisfied.

By keep moving or placing the pieces, we can reach to the goal state where number of
conflicts is zero, which means that there is no any queen that could attach any other queen

©Manning Publications Co. To comment go to liveBook


32

horizontally, vertically or diagonally. Listing 2.2 is a Python implementation of the 4-Queen


problem.

Listing 2.2 N-Queen CSP


from copy import deepcopy
import math
import matplotlib.pyplot as plt
import numpy as np

board_size = 4
board = np.full((board_size, board_size), False) #A

def can_attack(board, row, col):


if any(board[row]): #B
return True #B

offset = col - row #C


if any(np.diagonal(board, offset)): #C
return True #C
offset = (len(board) - 1 - col) - row #C
if any(np.diagonal(np.fliplr(board), offset)): #C
return True #C

return False

board[0][0] = True #D
col = 1
states = [deepcopy(board)]
while col < board_size:
row = 0
while row < board_size:
if not can_attack(board, row, col): #E
board[row][col] = True
col += 1
states.append(deepcopy(board))
break
row += 1
if row == board_size: #F
board = np.delete(board, 0, 1)
new_col = [[False]] * board_size
board = np.append(board, new_col, 1)
states.append(deepcopy(board))
col -= 1
continue

#A Create an nxn board


#B Check existing on the same row
#C Check diagonals
#D First column is trivial
#E The piece can be placed in this column
#F The piece cannot be placed in this column

We define a function called can_attack to detect if a newly placed piece can attack a
previously placed piece. A piece can attack another piece if it is in the same row, column, or
diagonal.

©Manning Publications Co. To comment go to liveBook


33

Figure 2.8 N-Queens Solution. The first piece is trivially placed in the first position. The second piece must be
placed either in the 3rd position or the 4th position, as the first two can be attacked. By placing it in the 3rd
position however, the 3rd piece cannot be placed. Thus, the first piece is removed (the board is “slid” one
column over), and we reattempt. This continues until a solution is found.

The full code for this problem, including the code used to generate visualizations, can be
found in the code file for Listing 2.2. The solution algorithm is as follows:

1. Moving from top to bottom in a column, the algorithm attempts to place the piece
while avoiding conflicts. For the first column, this will default to Q1 = 0.
2. Moving to the next column, if a piece cannot be placed at row 0, it will be placed at
row 1, and so on.
3. When a piece has been placed, the algorithm moves to the next column.
4. If it is impossible to place a piece in a given column, the first column of the entire
board is removed, and the current column is reattempted.
Constraint programming solvers available in Google OR-Tools can be also used to solve
this n×n queen problem. Listing 2.3 shows the steps of the solution using OR-Tools.

©Manning Publications Co. To comment go to liveBook


34

Listing 2.3 Solving N-Queen problem using OR-Tools


import numpy as np
import matplotlib.pyplot as plt
import math
from ortools.sat.python import cp_model #A

board_size = 4 #B

model = cp_model.CpModel() #C

queens = [model.NewIntVar(0, board_size - 1, 'x%i' % i) for i in range(board_size)] #D

model.AddAllDifferent(queens) #E

model.AddAllDifferent(queens[i] + i for i in range(board_size))


model.AddAllDifferent(queens[i] - i for i in range(board_size))

solver = cp_model.CpSolver() #G
solver.parameters.enumerate_all_solutions = True #G
solver.Solve(model) #G

all_queens = range(board_size) #F
state=[]
for i in all_queens:
for j in all_queens:
if solver.Value(queens[j]) == i:
# There is a queen in column j, row i.
state.append(True)
else:
state.append(None)

states=np.array(state).reshape(-1, board_size)
fig = plt.figure(figsize=(5,5)) #H
markers = [
x.tolist().index(True) if True in x.tolist() else None
for x in np.transpose(states)
] #H
res = np.add.outer(range(board_size), range(board_size)) % 2 #H
plt.imshow(res, cmap="binary_r") #H
plt.xticks([]) #H
plt.yticks([]) #H
plt.plot(markers, marker="*", linestyle="None", markersize=100/board_size, color="y") #H

#A imports a constraint programming solver that uses SAT (satisfiability) methods.


#B Set board size for nxn Queeen problem.
#C Define a solver
#D Define the variables. The array index represents the column, and the value is the row.
#E Define the constraint: all rows must be different
#F Define the constraint: no two queens can be on the same diagonal.
#G Solve the model.
#H Visualize the solution

Running this code produces the following output:

©Manning Publications Co. To comment go to liveBook


35

Figure 2.9 N-Queens solution using OR-Tools.

More information about Google OR-Tools is available in Appendix A.

2.1.3 Constraints
Constrained problems have equality and/or inequality hard or soft constraints. Hard
constraints must be satisfied, while soft constraints are nice to satisfy (but are not
mandatory). If there are no constraints to be considered aside from the boundary
constraints, the problem is an unconstrained optimization problem. Let’s revisit the ticket
pricing problem introduced in subsection 1.3.1 of the previous chapter. There a wide range of
derivative-based solvers in Python that can handle such kind of differentiable mathematical
optimization problem (see Appendix A). Listing 2.4 shows how to solve this simple ticket
pricing problem using SciPy. SciPy is a library containing a collection of valuable tools for all
things computation.

Listing 2.4 Optimal Ticket Pricing


import numpy as np
import scipy.optimize as opt
import matplotlib.pyplot as plt

def f(x): #A
return -(-20*x**2+6200*x-350000)/1000

res=opt.minimize_scalar(f, method='bounded', bounds=[0, 250]) #B

print("Optimal Ticket Price ($): %.2f" % res.x)


print("Profit f(x) in K$: %.2f" % -res.fun)

#A The objective function, which is required by ‘minimize_scalar’ to be a minimization function


#B ‘bounded’ method is the constrained minimization procedure that finds the solution

Running this code produces the following output:

©Manning Publications Co. To comment go to liveBook


36

Optimal Ticket Price ($): 155.00


Profit f(x) in K$: 130.50

This code finds the optimal ticket price in the range between $0 and $250 that maximizes
the profit. As you may have noticed the profit formula is converted into a minimization
problem by adding a negative sign in the objective function to match with the minimize
function in scipy.optimize. A minus sign was added in print function to convert it back into
profit.
What if we imposed an equality constraint on this problem? Let’s assume that due to
incredible international demand for our event, we now consider using a different event
planning company and opening up virtual attendance for our conference, so that
international guests can also participate. Interested participants can now choose between
attending the event in person or joining via live stream. All participants, whether in-person
or virtual, will still receive a physical welcome package, which is limited to 10,000 units.
Thus, in order to ensure a “full” event, we must either sell 10,000 in person tickets, 10,000
virtual tickets, or some combination thereof. This new event company is charging us a
$1,000,000 flat rate for the event, and thus we want to sell as many tickets as possible
(exactly 10,000). Below are the equations associated with this problem:
Let x be the number of physical ticket sales, and y be the number of virtual ticket sales.
Additionally, let f(x,y) be the function for profits generated from the event, where

f(x,y)=155x+(0.001x3/2+70)y-1000000

Equation 2.2

Essentially, we earn $155 profit on in-person attendance, and the profit for online
attendance is $70, but increases by some amount the more physical attendance we have
(let’s say that as the event looks “more crowded”, we can charge more for online attendees).
Assuming that we’re adding the constraint function: x+y≤10000, which shows that the
combined ticket sales cannot exceed 10,000. The problem is now a bivariate mono-objective
constrained optimization problem. It is possible to convert this constrained optimization
problem to unconstrained optimization using Lagrange multiplier λ. We can use sympy to
implement Lagrange multipliers to solve for the optimal mix of virtual and physical ticket
sales. The idea is to take the partial derivatives of the objective functions and the constraints
with respect to the decision variables x and y to form the unconstrained optimization
equations to be used by the SymPy solver as illustrated in Figure 2.10.

©Manning Publications Co. To comment go to liveBook


37

Figure 2.10 Steps of solving ticket pricing problem using Lagrange method

Listing 2.5 shows the Python implementation using SymPy. SymPy is an open-source
Python library for symbolic mathematics. Capabilities include, but are not limited to,
statistics, physics, geometry, calculus, equation solving, combinatorics, discrete math,
cryptograph and parsing. See Appendix-A for more information about SymPy.

Listing 2.5 Maximizing Profits using Lagrange Multipliers


import numpy as np
import sympy as sym

x,y=sym.var('x, y', positive=True) #A

f=155*x+(0.001*x**sym.Rational(3,2)+70)*y-1000000 #B

g=x+y-10000 #C

lamda=sym.symbols('lambda') #D
Lagr=f-lamda*g

grad_Lagr=[sym.diff(Lagr,var) for var in [x,y]] #E


eqs=grad_Lagr+[g]

sol=sym.solve(eqs,[x,y,lamda], dict=True) #F

def getValueOf(k, L):


for d in L:
if k in d:
return d[k]

# print the value of the objective function


profit=[f.subs(p) for p in sol]

print("optimal number of physical ticket sales: x = %.0f" % getValueOf(x, sol))


print("optimal number of online ticket sales: y = %.0f" % getValueOf(y, sol))
print("Expected profil: f(x,y) = $%.4f" % profit[0])

©Manning Publications Co. To comment go to liveBook


38

#A define decision variables


#B define the ticket pricing objective function
#C define equality constraint
#D Lagrange multiplier
#E taking the partial derivatives
#F solving these 3 equations in 3 variables (x,y,lambda) using sympy

By solving the above three equations, we get x and y values that correspond to the
optimized quantities for virtual and physical ticket sales. From Listing 2.5, we can see that
the best way to sell tickets is to sell 6,424 in-person tickets and 3,576 online ticket profits.
This results in a maximum profit of $2,087,260.533.

2.1.4 Linearity of Objective Functions and Constraints


If all the objective functions and all associated constraint conditions are linear, the
optimization problem is categorized as a linear optimization problem or Linear Programming
Problem (LPP or LP), where the goal is to find the optimal value of a linear function subject to
linear constraints. Blending problems are a typical application of mixed integer linear
programming (MILP) where a number of ingredients are to be blended or mixed to obtain a
product with certain characteristics or properties. In the animal feed mix problem described
in [4], it is required to determine the optimum amounts of three ingredients to include in an
animal feed mix. The possible ingredients, their nutritive contents (in kilograms of nutrient
per kilograms of ingredient) and the unit cost are shown in Table 2.1.

Table 2.1 Animal Feed Mix Problem

Nutritive content and price of ingredients


Ingredients
Calcium (kg/kg) Protein (kg/kg) Fiber (kg/kg) Unit cost (cents/kg)

Corn 0.001 0.09 0.02 30.5

Limestone 0.38 0.0 0.0 10.0

Soybean meal 0.002 0.50 0.08 90.0

The mixture must meet the following restrictions:


• Calcium — at least 0.8% but not more than 1.2%.
• Protein — at least 22%.
• Fiber — at most 5%.
The problem is to find the mixture that satisfies these constraints while minimizing cost.
The decision variables are x1, x2 and x3, which are proportions of Limestone, Corn and
Soybean meal in the mixture respectively.
Objective Function: minimize f = 30.5x1 + 10x2 + 90x3
Subject to the following constraints:
• Calcium limits: 0.008<=0.001x1+0.38x2+0.002x3 <=0.012
• Protein constraint: 0.09x1+0.5x3 >=0.22
• Fiber constraint: 0.02x1+0.08x3 <=0.05
• Non-negativity restriction: x1, x2, x3 >= 0

©Manning Publications Co. To comment go to liveBook


39

• Conservation: x1+x2+x3=1
In this problem, both the objective function and the constraints are linear so we call it
linear programming problem. There are several Python libraries that can be used for solving
mathematical optimization problems (see Appendix A). Let’s consider solving the animal feed
mix problem using PuLP. PuLP is a Python linear programming library. It allows users to
define linear programming problems and to solve them using optimization algorithms such as
COIN-OR's linear and integer programming solvers. See Appendix A for more information
about PuLP and other mathematical programming solvers. Listing 2.6 shows the steps of
solving the animal feed mix problem using PuLP.

Listing 2.6 Solving Linear Programming Problem using PuLP


from pulp import *

model = LpProblem("Animal_Feed_Mix_Problem", LpMinimize) #A

x1 = LpVariable('Corn', lowBound = 0, upBound = 1, cat='Continous') #B


x2 = LpVariable('Limestone', lowBound = 0, upBound = 1, cat='Continous') #B
x3 = LpVariable('Soybean meal', lowBound = 0, upBound = 1, cat='Continous') #B

model += 30.5*x1 + 10.0*x2 + 90*x3, 'Cost' #C

model +=0.008 <= 0.001*x1 + 0.38*x2 + 0.002*x3 <= 0.012, 'Calcium limits' #D
model += 0.09*x1 + 0.5*x3 >=0.22, 'Minimum protein' #D
model += 0.02*x1 + 0.08*x3 <=0.05, 'Maximum fiber' #D
model += x1+x2+x3 == 1, 'Conservation' #D

model.solve() #E

for v in model.variables(): #F
print(v.name, '=', round(v.varValue,2)*100, '%') #F

print('Total cost of the mixture per kg = ', round(value(model.objective), 2), '$') #F

#A Create a linear programming model


#B Define 3 variables that represents the percentage of each ingredients Corn, Limestone and Soybean meal in the
mixture.
#C Define total cost as the objective function to be minimize
#D Add the constraints
#E Solve the problem using PuLP's choice of Solver
#F Print the results (the optimal percentages of the ingredients and the cost of the mixture per kg)

As you can see in this listing, we start by importing PuLP and creating a model as linear
programming problem. We then define LP Variables with the specified associated parameters
such as name, lower bound and upper bound on each variable’s range and type of the
variable (e.g., Integer, Binary or Continuous). A solver is then used to solve the problem.
PuLP supports several solvers such as GLPK, GUROBI, CPLEX and MOSEK. The default solver
in PuLP is Cbc (Coin-or branch and cut). Running this code gives the following output:

Corn = 65.0%
Limestone = 3.0%
Soybean_meal = 32.0%
Total cost of the mixture per kg = 49.16$

©Manning Publications Co. To comment go to liveBook


Discovering Diverse Content Through
Random Scribd Documents
residencia de cómo mandó hacer las dichas llaves, e la ponga en
esta su respuesta, según que ante mí pasó por dos veces, e
ansimismo ponga testimonio de que hace presentación, e más otro
testimonio de Pero Pérez, escribano, con el cual el dicho señor
Licenciado les mandó por dos veces que tomasen las dos de las
dichas llaves, lo cual los dichos regidores no quisieron hacer, antes
tomaron y escondieron las dichas escripturas para quel dicho señor
Licenciado no las vea, especialmente porque supieron quel dicho
señor Licenciado quería ver algunas ordenanzas que no estaban
conforme á justicia, entre las cuales está una que da licencia á
Jerónimo de Alanís, lego e persona sin letras, para que pueda
abogar, porque les dé dos toros, estando prohibido como está por Su
Majestad, por muchas provisiones, que no haya abogados en esta
isla, como es público e notorio e se contiene en la dicha ordenanza.
Yo Jerónimo de Alanís, escribano de Sus Majestades y escribano
del concejo de esta cibdad de Santiago de esta isla Fernandina, doy
fe á todos los que la presente vieren, que hoy día de la fecha de
ésta, por mi presencia, el muy noble señor licenciado Juan
Altamirano, juez de residencia e teniente de gobernador en esta isla,
mandó notificar á los regidores desta dicha cibdad que compren ó
fagan tener dos arcas, la una para tener en la cárcel pública desta
dicha cibdad, e la otra para las escripturas del cabildo, lo cual que
dicho es, en el dicho día, yo el dicho escribano notifiqué al contador
Pero de Paz e á Gonzalo de Guzmán e al tesorero Pero Núñez de
Guzmán, en sus personas, regidores, según que más largamente se
contiene en los abtos que sobre ello pasaron á que me refiero, lo
cual pasó en la dicha cibdad de Santiago á nueve días del mes de
junio de mill e quinientos e veinte e cinco años.—Jerónimo de Alanís,
escribano.
Yo Pero Pérez, escribano de su Majestad y escribano público
desta cibdad de Santiago e del juzgado del muy noble señor
licenciado Juan Altamirano, teniente de gobernador en esta dicha
isla Fernandina por Su Majestad, e por su Virrey, doy e fago fe á
todos los que la presente vieren, que Dios honre e guarde, cómo en
catorce días del mes de agosto, año del nascimiento de Nuestro
Salvador Jesucristo de mill e quinientos e veinte y cinco años, el
dicho señor Licenciado mandó á mí el dicho escribano notifique á
Gonzalo de Guzmán e al tesorero Pero Nuñez de Guzmán e á los
demás regidores que pudieren ser habidos, que para mañana en
todo el día parezcan e se junten con él para que vean las provisiones
e mercedes que esta isla tiene e las metan en una caja e se eche
suerte á cuál dellos cabrá la llave della, porque ansí conviene al
servicio de su Majestad e á la buena gobernación de la isla, e si lo
hicieren, harán bien, donde no quél hará sobre ello lo que sea
justicia.
Este dicho día, yo el dicho escribano notifiqué lo susodicho al
dicho tesorero e á Gonzalo de Guzmán, regidores, en sus personas.
Testigos Martín de Zárate e Pelayo Briceño.
Otrosí, yo el dicho escribano doy fe cómo en diez e ocho días del
dicho mes de agosto e año susodicho, por mandado del dicho señor
Licenciado, yo el dicho escribano notifiqué al contador Pero de Paz e
á Gonzalo de Guzmán e al tesorero Pero Núñez de Guzmán e á
Andrés de Duero, regidores, que para hoy en todo el día se junten
con él como por otra notificación que le fué fecha se lo mandó
apercibir, para que les dé una arca con su llave á donde estén las
provisiones e otras cosas tocantes al concejo, para que cada fuese
nescesario para la buena gobernación las vean e se haga lo que
convenga, e para que se eche por suerte á quién le cabrá la llave de
la dicha arca, con apercibimiento que no lo haciendo, quel hará en
ello lo que le pareciere que debe conforme á justicia. Testigos
Andrés Muñoz e Rodrigo de Ayala e Alonso de Barrante e Antonio de
Valladolid, e yo el dicho escribano presente fuí, e lo hice escrebir.
Otrosí, cuanto al séptimo capítulo quel dicho Rodrigo Durán hizo
relación el dicho señor Licenciado haber tomado las llaves de la casa
de la fundición, diz que á efecto que no se hiciese fundición sin que
lo supiese el dicho señor Licenciado, dijo la dicha relación no ser
verdadera, antes careciente de toda verdad, según e como en todas
las susodichas, porquel dicho señor Licenciado no había tomado la
dicha llave al efecto que no se hiciese la dicha fundición, e que si
algún día la había tenido sería porque el veedor se la había traído,
que se iba fuera, e no porquél quisiese estorbar ni impedir que no
hoviese la dicha fundición alguna, antes todas las veces que fué
menester la dió, e luego la dió á Santa Clara, fundidor de la dicha
casa, e que no hay provisión ni merced de Su Majestad para que no
entre en la dicha casa, ni sería servicio de Su Majestad quél dejase
de entrar, e que á cabsa de cierta información que quería tomar de
los dichos oficiales de Su Majestad, de ciertas cosas que habian
venido á su noticia, que en la dicha fundición habían fecho los dichos
oficiales, no sabe por qué no quisieron jurar, poniendo en cabsas
indecisas, diciendo que los jueces no podían conocer en la dicha
cabsa, e diciendo tener provisión para ello de su Majestad, la cual
puesto que dijeron que la traerían, por excusarse de dicho
juramento, después nunca la trajeron, ni la ha habido, ni hay en esta
dicha isla, antes los dichos oficiales, por ser cosa que toca al servicio
de su Majestad e cosas que dirían que se habían fecho en la dicha
casa de la fundición, habían de jurar de sus dichos, para se apartar
de todo lo que se les ponía, e dijo que por los dichos testimonios e
probanzas con la notoriedad de cada uno de los dichos capítulos e
respuestas á ellos, vería su Majestad e los dichos señores oidores las
dichas peticiones dadas por el dicho Rodrigo Durán, en que dijo el
dicho señor Licenciado haber fecho agravio á los vecinos desta isla,
e que de aquí adelante los agraviaría, e las peticiones por donde se
movieron á proveer, como proveyeron, ser como dicho es, ganadas
con siniestra fe en su relación e callando la verdad, de manera que si
no callara, los dichos señores oidores no se movieran á proveer
como proveyeron, porque pedía e pidió á los dichos señores oidores
mandasen reponer e repusiesen cada uno de los dichos capítulos e
provisiones, e le dejasen libremente usar según e como su Majestad
mandaba en la dicha su provisión, e que si necesario era, hablando
con el debido acatamiento, protestando como protestaba no atribuir
en ello á los señores oidores más jurisdicción de la que de Su
Majestad toviesen, suplicándole una e dos e más veces e todas
aquellas que de derecho era obligado, le envíen e muestren el poder
que de su Majestad tienen para mandar el que no use de su
jurisdicción, como Su Majestad lo manda, porque en lo que
paresciere los dichos señores oidores tener poder de Su Majestad,
está con todo acatamiento de lo tener e complir e guardar según e
como es obligado, y en lo demás que no lo toviesen pide y suplica le
dejen usar de su provisión, pues su Majestad lo envió á esta isla á
ello, e que de los dichos capítulos e cada uno dellos, fablando con el
dicho debido acatamiento, salvo jure militatis, dijo que suplicaba e
suplicó ante Sus Majestades e los señores de su muy alto Consejo
de las Indias, e que ansí protestaba e protestó de se presentar
personalmente ó como mejor debiese, con cuya protección y
amparo, etc. E pidiólo por testimonio, e pidió á mi el dicho escribano
esta dicha respuesta ponga al pie de la notificación que le fué fecha.
Testigos que fueron presentes, Francisco Osorio e Juan de la Torre.—
Licenciatus Altamirano. Va escripto este testimonio en diez e ocho
hojas de pliego entero. Está rublicado de mi rública e señal de mí el
dicho escribano. E yo el dicho Jerónimo de Alanís, escribano
susodicho, lo fice escribir et fiz aquí este mi signo á tal en testimonio
de verdad.—Jerónimo de Alanís, escribano.—Hay un signo.—Hay una
rúbrica.
74.

(1525.—Diciembre 1.)—Real cédula previniendo que los tenientes de gobernador


no entren en cabildo con los alcaldes ordinarios y regidores, en las villas y
lugares.—A. de I., 139, 1, 7.
75.

(1525.—Diciembre 9.)—Real cédula ordenando al presidente y oidores de la


Audiencia de la Española que no pongan impedimento á la salida de
mantenimientos destinados á la isla Fernandina.—A. de I., 139, 1, 6.
76.

(1525.—Diciembre 15.)—Real cédula encargando á Gonzalo de Guzmán que tome


residencia al licenciado Altamirano y confirmándole en el cargo de teniente
gobernador de la isla que le confirió el almirante D. Diego Colón.—A. de I., 53,
6, 4.

Don Carlos, por la gracia de Dios, Rey de romanos e Emperador


semper augusto; D.ª Juana, su madre, y el mismo D. Carlos, por la
misma gracia Reyes de Castilla, de León, etc.
Por cuanto por algunas causas cumplideras á nuestro servicio e á
la ejecución de la nuestra justicia e á la administración della en la
isla Fernandina, enviamos á mandar á vos, Gonzalo de Guzmán,
nuestro criado, vecino e regidor de la cibdad de Santiago de la dicha
isla, que toméis residencia al licenciado Altamirano, nuestro juez de
residencia e lugarteniente de nuestro gobernador della, et á sus
oficiales, del tiempo que han tenido el dicho cargo, según que más
largamente en las provisiones que dello vos habemos mandado dar
se contiene, y el almirante D. Diego Colón vos ha nombrado por
lugarteniente de nuestro gobernador de la dicha isla, por ende
confiando de vos que sois tal persona que guardaréis nuestro
servicio[10] en ello con aquella diligencia e fidelidad e buen..... que á
nuestro servicio cumple e á la buena ejecución de la nuestra justicia
e bien común de la dicha tierra e vecinos e moradores della, por la
presente mandamos al concejo, justicia e regidores, caballeros,
escuderos, oficiales e homes buenos de la dicha cibdad de Santiago
de la isla Fernandina, e á todas las otras cibdades, villas e logares
della, que fecho por vos el juramento e solenidad que en tal caso se
requiere e debéis hacer, vos hayan e reciban e tengan por
lugarteniente de nuestro gobernador de la dicha isla e su tierra,
entre tanto e hasta que se provea otra cosa en contrario, e dejen e
consientan libremente tener e usar y ejercer y ejecutar la nuestra
justicia por vos et por vuestros oficiales e lugarteniente en los casos
e cosas al dicho oficio de lugarteniente de nuestro gobernador de la
dicha isla anejos e pertenecientes, e como lo han hecho e usado e
debido hacer e usar con los otros nuestros lugartenientes de
gobernadores que han seido e son de la dicha isla, e como tal
nuestro gobernador podáis oir e oigáis, determinar e determinéis los
pleitos e causas ceviles et criminales que en la dicha isla están
pendientes, comenzados e movidos, y que en cuanto por Nos
tuviéredes el dicho oficio se comenzaren e movieren, e hacer
cualesquier pesquisas en los casos de derecho, premisas al dicho
oficio pertenescientes, y que vos entendáis que á nuestro servicio y
ejecución de la nuestra justicia cumplan, e para usar y ejercer el
dicho oficio todos se conformen con vos et con sus personas e
gentes vos den e hagan dar todo el favor et ayuda que les pidierdes
y menester hobierdes, e que en ello ni en parte dello embargo ni
contrario alguno vos no pongan ni consientan poner, que Nos por la
presente vos rescibimos e habemos por rescibido al dicho oficio de
lugarteniente de nuestro gobernador de la dicha isla, e vos damos
poder para usar y ejercer el dicho oficio y ejecutar la nuestra
justicia, caso que por ellos ó por algunos dellos á él no seais
rescebido, por cuanto ansí cumple á nuestro servicio, no embargante
cualesquier estatutos ó costumbre que cerca dello haya, y por esta
nuestra carta mandamos á cualesquier persona ó personas que
tienen las varas de la nuestra justicia e de los dichos oficios de
alcaldías desa dicha isla e su tierra, que luego vos las den y
entreguen e no usen más dellas sin nuestra licencia y mandado, so
las penas en que caen e incurren las personas privadas que usan de
oficios públicos para que no tienen poder ni facultad, que Nos por la
presente los suspendemos e habemos por suspendidos en los dichos
oficios, y es nuestra merced que si vos, el dicho Gonzalo de Guzmán,
entendiéredes ques cumplidero á nuestro servicio e á la ejecución de
la nuestra justicia y administración della que cualesquier caballeros ó
otras personas vecinos de la dicha isla ó de fuera della que á ella
vinieren y en ella estén, salgan della, e que no entren ni estén en
ella, y que se vengan á presentar ante Nos, que vos lo podáis
mandar de nuestra parte, e los hagáis dello saber, á los cuales á
quien vos lo mandardes, Nos por la presente mandamos que luego
sin os más requerir ni consultar sobre ello ni esperar otra nuestra
carta..... segunda ni tercera jusión y sin interponer dello apelación ni
suplicación, lo pongan en obra, según que lo vos dijéredes e
mandáredes, so las penas que les pusierdes de nuestra parte, las
cuales Nos por la presente les ponemos e habemos por puestas, e
vos damos poder e facultad para las ejecutar en los que rebeldes e
inobedientes fueren, y mandamos á vos, el dicho Gonzalo de
Guzmán, que conozcáis de todas las cabsas e negocios que están
por vos cometidos á los gobernadores e jueces de residencia que
han sido de la dicha isla, e toméis los procesos en el estado que los
halláredes, atento el tenor e forma de las cartas e provisiones que
les fueron dadas, e hagáis á las partes cumplimiento de justicia, bien
ansí e tan complidamente como si á vos fuesen dirigidas y
enderezadas, que para ello vos damos poder cumplido y para usar y
ejercer el dicho oficio y cumplir y ejecutar la nuestra justicia en
todas sus incidencias e dependencias emergencias, anexidades e
conexidades, e otrosí mandamos á vos, el dicho Gonzalo de
Guzmán, que llevéis e tengáis los capítulos que mandamos guardar
á los corregidores de nuestros reinos, e los presentéis en el dicho
concejo al tiempo que fuéredes rescebido al dicho oficio, e que los
hagáis escrebir e poner en un pergamino ó papel, e los hagáis poner
en las casas del ayuntamiento de la dicha cibdad, y que guardéis lo
contenido en los dichos capítulos, con apercebimiento que, si no los
tuviéredes e guardáredes, será procedido contra vos por todo rigor
de justicia por cualquiera de los dichos capítulos que se hallare no
haber guardado, no embargante que digáis que dello no supistes, e
otrosí mandamos al concejo, justicia e regidores, caballeros,
escuderos, oficiales e homes buenos de la dicha cibdad de Santiago,
que al tiempo que os rescibieren por lugarteniente de nuestro
gobernador de la dicha isla, tomen e resciban de vos fianzas llanas e
abonadas que haréis la residencia que las leyes de nuestros reinos
mandan; otrosí mandamos que las penas pertenescientes á nuestra
cámara e fisco en que vos ó vuestros oficiales condenarédes, e las
que para la nuestra cámara se aplicaren e pusieren, las ejecutéis e
pongáis en poder del escribano del concejo de la cibdad ó villa ó
lugar donde fueren condenadas, por inventario e ante escribano
público, y de allí hagáis que se acuda con ellas al nuestro tesorero
de la dicha isla. Dada en Toledo á quince días del mes de diciembre
año del nascimiento de nuestro Señor Jesucristo de mill e quinientos
et veinte e cinco años.—Yo el Rey.—Francisco de los Cobos,
secretario de sus cesáreas y católicas, lo hizo escrebir por su
mandado.—Canciller.—Fr. G. Episcopus Oxonensis.—Dotor Carvajal.—
Dotor Beltrán.—G. Episcopus Civitatensis.
77.

(1525.—Diciembre 15.)—Real provisión en consecuencia de la cédula anterior,


sobre la residencia que Gonzalo de Guzmán ha de tomar al licenciado
Altamirano.—A. de I., 139, 1, 6.
78.

(1525.—Diciembre 15.)—Real provisión á Gonzalo de Guzmán para que tome


residencia al licenciado Altamirano, encargándose del gobierno. Proceso, cargos
y descargos del referido Licenciado.—A. de I., 47, 2, 8/3.

Don Carlos, por la gracia de Dios, Rey de romanos: D.ª Juana, su


madre, y el mismo D. Carlos, por la misma gracia Reyes de Castilla,
de León, etcétera. A vos, Gonzalo de Guzmán, vecino e regidor de la
cibdad de Santiago de la isla Fernandina, salud e gracia. Sepades
que por cabsas complideras á nuestro servicio e á la ejecución de
nuestra justicia, e á la buena gobernación e administración de la
dicha isla, e á suplicación della e de sus pueblos, nuestra merced e
voluntad es de mandar tomar residencia al licenciado Altamirano,
nuestro juez de residencia de la dicha isla e lugarteniente de nuestro
gobernador della e á sus oficiales, e confiando de vos, que sois tal
persona que entenderéis en ello e en todo lo que por Nos os fuere
mandado e encomendado con aquella deligencia e fidelidad e buen
recabdo que á nuestro servicio cumple e á la buena ejecución de la
nuestra justicia e bien común de la dicha isla e vecinos e moradores
della, nuestra merced e voluntad es de os lo encomendar e cometer,
e por la presente os lo encomendamos e cometemos, porque nos
mandamos que luego que esta carta vos fuere notificada toméis en
vos las varas de la nuestra justicia e alcaldías e otros cargos e oficios
susodichos que ha tenido el dicho licenciado Altamirano, e toméis
dellos e de cada uno dellos residencia por término de cincuenta días,
e cumpláis de justicia á los que dellos hobiere querellosos,
sentenciando las dichas cabsas conforme á justicia e á lo que está
mandado por las provisiones e ordenanzas de los católicos Reyes
nuestros padres e abuelos e señores, que hayan santa gloria, e por
Nos hayan sido dadas á la dicha isla en razón de lo susodicho, la
cual dicha residencia mandamos al dicho licenciado Altamirano e á
los dichos sus oficiales que la hagan ante vos como dicho es, e que
para la hacer vengan e parezcan ante vos personalmente en el lugar
donde vos residierdes e estén en él presentes durante el dicho
tiempo de la dicha residencia, so las penas contenidas en las leyes e
premáticas destos reinos que sobre esto disponen, e otrosí vos
mandamos que os informéis de vuestro oficio cómo e de qué
manera el dicho licenciado Altamirano e sus oficiales han usado el
dicho oficio ejecutando la nuestra justicia, especialmente en los
pecados públicos, cómo se han guardado las leyes hechas en las
Cortes de Toledo, e las ordenanzas e instrucciones de los católicos
Reyes nuestros padres e abuelos e señores, que hayan santa gloria,
e nuestras, e cómo han guardado e defendido la nuestra justicia,
derecho e preminencia Real, e si en algo los hallardes culpantes por
la información secreta, llamadas e oídas las partes averigüéis la
verdad, e así averiguada hagáis sobre todo ello complimiento de
justicia conforme á los capítulos de los corregidores, e fecha lo
enviéis todo ante Nos, e asimismo hayáis información de las penas
en que los dichos licenciado Altamirano e sus oficiales les han
condenado á cualesquier concejos e personas, pertenecientes á
nuestra cámara e fisco, e las cobréis dellos e las déis e entreguéis al
nuestro tesorero de la dicha isla ó á quien su poder hobiere,
haciéndole cargo dellas, e asimismo toméis residencia á los
regidores de las cibdades, villas e lugares de la dicha isla que no la
hayan hecho después que por Nos fueron proveídos, e cómo e de
qué manera han usado e ejercido los dichos oficios, e si han ido e
pasado contra las leyes hechas en las Cortes de Toledo e contra lo
que está mandado e ordenado por los dichos católicos Reyes e por
Nos en lo que á ellos incumbe e si en algo los hallardes culpados por
la información secreta, les déis treslado della e recibáis sus
descargos, e averiguada la verdad de todo ello hagáis e determinéis
en ello lo que hallardes por justicia, que Nos por la presente,
durante el dicho tiempo de la dicha residencia, e más cuanto nuestra
voluntad fuere, suspendemos al dicho licenciado Altamirano e sus
oficiales de los dichos oficios e cargos, e les mandamos que no usen
más dellos sin nueva expresa facultad e provisión nuestra. Dada en
Toledo á quince días del mes de diciembre de mill e quinientos e
veinte..... años.—Yo el Rey.—Yo Francisco de los Cobos, secretario de
sus cesárias Majestades, lo fice escrebir por su mandado.—
Registrada, Juan de Sámano.—Frey García, episcopus.—Pedro
Gómez Orbina.—Asentóse esta provisión de Sus Majestades en los
libros de la Casa de la Contratación de Sevilla, en nueve días del mes
de enero de mill e quinientos e veinte e seis años, por D. Domingo
de Ochadiano.

Información acerca de las grandes distancias que hay en la isla y


dificultades que esto ofrece.
En la cibdad de Santiago desta isla Fernandina del mar Océano,
viernes veinte e siete días del mes de abril de mill e quinientos e
veinte e seis años, el muy noble señor Gonzalo de Guzmán, juez de
residencia e teniente de gobernador en esta dicha isla por Sus
Majestades, e en presencia de mí, Juan de la Torre, escribano de Su
Majestad e del Abdiencia e juzgado del dicho señor Gonzalo de
Guzmán, dijo que por cuanto Su Majestad le manda tome residencia
al licenciado Juan Altamirano, juez de residencia e teniente de
gobernador que fué, del tiempo que usó de los dichos oficios, así á
él como á sus lugarestenientes e otros oficiales, e á los regidores e
alcaldes desta cibdad e de las otras villas desta isla, por cierto
tiempo, atento en las provisiones de Su Majestad, la cual si la
hobiese de tomar haciendo venir personalmente á la hacer los
dichos tenientes, alguaciles e regidores que Su Majestad manda que
la hagan, según la mucha distancia de camino que hay de las dichas
villas á esta cibdad, recibirían mucho daño e pérdida en sus
haciendas, e demás de lo susodicho, el dicho señor Gonzalo de
Guzmán es informado que en cada una de las provincias de las
dichas villas andan e están muchos indios alzados e rebelados
haciendo muchos males e muertes de españoles e indios e haciendo
otros robos e insultos, así en caminos como fuera dellos, e si los
susodichos tenientes e oficiales hobiesen de venir en persona e los
dichos indios viesen los pocos españoles que en las dichas villas
estaban, venidos los susodichos, podrían alzarse del todo e hacer
más mal de lo que hasta aquí han fecho, por ende, que para proveer
lo susodicho lo que convenga al servicio de Su Majestad e bien desta
isla que para información sobrello hizo parescer ante sí á las
personas siguientes.
E luego el dicho señor Gonzalo de Guzmán hizo parescer ante sí
á García de Barreda e Andrés Muñoz, vecinos desta dicha cibdad, e
Alonso de Hinojosa, vecino de la villa de Puerto del Príncipe, de los
cuales e de cada uno dellos el dicho señor Gonzalo de Guzmán tomó
é recibió juramento en forma debida de derecho, e lo que dijeron e
depusieron, seyendo preguntados por el tenor de lo susodicho, es
esto que se sigue:
García de Barreda, vecino de esta cibdad, testigo rescibido para
información de lo susodicho, habiendo jurado, dijo: que lo que se
sabe deste caso es queste testigo ha estado en algunos lugares
desta isla e sabe que el lugar más cerca desta cibdad que es el
Puerto del Príncipe, adonde hay teniente, hay cerca de cien leguas, e
que en otros están á ciento e cincuenta e otros á docientas, e á
docientas e cincuenta, e que por esta otra banda, questá Baracoa,
hay sesenta e cinco leguas poco más ó menos, e queste testigo le
paresce e sabe quél y los dichos tenientes e alguaciles e regidores
de cada una de las dichas villas hobiesen de venir á esta cibdad
personalmente á hacer residencia, rescibirían mucho daño así en sus
haciendas como en sus personas, e que este testigo ha oido decir
que en todas las dichas provincias de la tierra adentro andan los
indios della muy alzados e rebelados e haciendo males e daños, e
han sucedido muertes de españoles e indios, e sabe este testigo e
tiene por cierto que si los dichos tenientes e alguaciles e regidores
viniesen en persona á esta dicha cibdad, los dichos indios se alzarían
del todo e harían otros muchos males viendo los pocos españoles
que quedasen e podría ser que tomasen atrevimiento á ir contra los
españoles que quedasen e que les quemasen los pueblos á causa de
los pocos españoles que en ellos quedaban, e que por lo susodicho,
so cargo del dicho juramento, le paresce más servicio de Dios
nuestro Señor e de Su Majestad que los dichos tenientes e alguaciles
e regidores hiciesen la dicha residencia en los dichos sus pueblos,
cometiéndose que se la tomen personas de confianza en las dichas
villas, e questa es la verdad para el juramento que hizo e firmólo de
su nombre, Barreda.
(Siguen declaraciones análogas de Andrés Muñoz y Alonso de
Hinojosa.)
E así tomada e rescibida la dicha información por el dicho señor
Gonzalo de Guzmán, dijo que atendiendo á la mucha distancia de
camino que hay desde las villas desta isla á esta cibdad, e que para
que en ellas se sepa de la residencia quel dicho Licenciado ha de
hacer, es necesario que se dé término para que los vecinos de las
dichas villas lo sepan, para que si alguno quisiere pedir alguna cosa
al dicho Licenciado no se queje que por no tener tiempo para poder
venir á esta cibdad en el término de la dicha residencia lo dejó de
hacer e perdió su justicia, mandaba e mandó quel término de la
dicha residencia quel dicho Licenciado e sus oficiales han de hacer,
comiencen á correr e se cuenten desde primero día del mes de
agosto primero que verná, e así mandó que se pregonase en esta
dicha cibdad e fué pregonado en ella, e mandó dar sus provisiones
para que en todas las dichas villas desta isla lo susodicho sea
pregonado, porque en todas sea notoria la dicha residencia.

················
E así presentado, el dicho señor Gonzalo de Guzmán dijo que lo
oyó e quél está presto de hacer lo que sea justicia e convenga al
servicio de Su Majestad, testigo Jerónimo Hernández e Suero de
Cangas, e que ayer lunes veinte e tres deste dicho mes lo
rescibieron en cabildo e hasta agora no ha entendido en cosa alguna
de lo que Su Majestad le manda.

················
E después desto, en la dicha cibdad de Santiago, lunes, treinta
días del dicho mes e del dicho año, el dicho señor Gonzalo de
Guzmán, en presencia de mí el dicho escribano, dijo respondiendo á
los requerimientos hechos por el dicho Licenciado, que si él ha
mandado pregonar quel término en que ha de hacer el dicho
Licenciado residencia que corra desde primero de agosto, ha seido
porquél tiene información de testigos de la mucha distancia de
camino que hay desde las villas desta isla á esta cibdad, adonde es
nescesidad, pues él ha seido juez en la dicha isla en todas las dichas
villas, e conviene al servicio de Su Majestad e bien de los vecinos
della que se sepa e sea notorio como el dicho Licenciado ha de
hacer la dicha residencia, porque si alguna persona dél se sintiere
agraviado ó de algunos de sus tenientes e oficiales, pidan su justicia,
si quisiere, como Su Majestad lo manda, e quel dicho Licenciado
hasta agora no tiene de qué ni por qué quejarse ni agraviarse,
porque como es notorio, el dicho señor Gonzalo de Guzmán, por
mandado de Su Majestad, ha solamente cuatro ó cinco días que
recibió el cargo e hasta agora él no ha entendido, salvo en lo que
conviene al servicio de Su Majestad, e informarse por testigos del
tiempo ques necesario que se dé para la dicha residencia, por
manera que en toda la isla sea notorio, e que en lo que dice que
tome letrado por asesor, que cuando sea tiempo él hará en ello lo
que Su Majestad le manda, e que si el dicho Licenciado dice que no
puede esperar el dicho tiempo á cabsa de la mucha costa que tiene
e que no es vecino desta isla, que á toda ella es notorio como él ha
tomado en sí e tiene indios en mucha cantidad, que son más de para
tres, e aun cuatro vecinos, especialmente los que fueron de Pedro
de Miranda, alcalde e vecino que fué en esta dicha cibdad, e los que
fueron de Rodrigo de Baeza, vecino desta dicha cibdad, e los que
fueron del adelantado Diego Velázquez, que haya gloria, que tenía
en la provincia de Bayte, entre los cuales, como es notorio, que
siendo el dicho Adelantado repartidor tomó los mejores de la dicha
provincia, e en más cantidad, con los cuales el dicho Licenciado, así
trayéndolos como los trae á sacar oro, como en otras granjerías que
en esta isla tiene, podían honestamente e muy bien los dichos tres ó
cuatro vecinos sustentarse, e que en lo que dice que habiendo seido
alcalde e regidor e heredero del dicho señor Adelantado el dicho
señor Gonzalo de Guzmán que Su Majestad había proveído que le
tomasen la dicha residencia, que como por las provisiones de Su
Majestad conste le fué notorio de todo lo susodicho, á cabsa de lo
cual él no tiene que decir cosa sobrello, salvo el dicho señor Gonzalo
de Guzmán complir lo que Su Majestad manda, e que como dicho
tiene, si él mandó que el término de la dicha residencia corriese
desde primero de agosto fué por lo que arriba se contiene, e demás
porque como es notorio en esta dicha isla, el dicho Licenciado ha
tenido en la villa de San Cristóbal de la Habana tratos e
contrataciones, e hay de la dicha villa á esta cibdad cerca de
trescientas leguas, e asimismo ha tenido las dichas contrataciones
en la villa de la Trenidad, que hay della á esta cibdad ciento e
cincuenta leguas, e más, como consta por la información que
sobrello ha recibido, á cabsa de lo cual mal podrían saber en las
dichas villas en los dichos cincuenta días como el dicho Licenciado e
sus oficiales han de hacer la dicha residencia, e que en lo que dice
que por haber sido juez ha de ser conservado e guardado mucho su
honor, que después quel dicho Licenciado dejó el dicho cargo e el
dicho señor Gonzalo de Guzmán le tiene, siempre lo ha tratado muy
bien e como él bien sabe, que con todos los buenos del pueblo ó con
la mayor parte dellos el dicho señor Gonzalo de Guzmán ha ido á la
posada del dicho Licenciado, ques en postrero de la dicha cibdad, á
le sacar e acompañar para que saliese á holgar e á pasear, e quél
todas las veces que fuere necesario tratar á su persona del dicho
Licenciado lo hará como á persona que ha tenido cargo de Su
Majestad, e quél y el dicho Licenciado sabe que alguna persona le
haya tratado después que dejó el dicho cargo de manera que no
deba, que siendo sabedor dello es presto de hacer cumplimiento de
justicia, e asimismo dijo quel bachiller Parada no sabe dónde está,
porque como es notorio á todos, no está en esta isla, por lo cual el
dicho señor Gonzalo de Guzmán no tiene que responder á lo sobrello
dicho por el dicho Licenciado, e questo da por respuesta no
consintiendo en sus protestaciones ni alguna dellas, e mandó á mí el
dicho escribano que si el dicho Licenciado pidiese testimonio no se lo
diese de esta su respuesta, e que vaya todo debajo de un signo.
Testigos que fueron presentes, Juan de Almagro e Andrés Ruano e
Gonzalo Hernández e Gonzalo de Guzmán.

················
Otrosí digo que ya su merced sabe como Pero Núñez de Guzmán
e su cuñado Pedro de Paz, oficiales de Su Majestad, e otras ciertas
personas, á causa de ciertas informaciones que en cosas
complideras al servicio de Su Majestad usando e teniendo yo el
cargo de teniente de gobernador en estas islas e por les haber
tomado residencia e condenádoles conforme á derecho, tovieron
formas como debajo de otras maneras se quejaron á Su Majestad
pidiendo residencia contra mí, e agora publicaron que porque no
queden falsos de lo que ansí escribieron á Su Majestad me ponen e
buscan quejas e demandas contra mí e por ser como son los dichos
oficiales hombres que tienen mano e muchas cosas que pueden
dañar á muchas personas, no osa procurador ni otra persona
ayudarme en las dichas cabsas, especial viendo como ven por la
manera que va e del amistad que vuestra merced con los dichos
oficiales e vecinos tiene, e agora el dicho señor Gonzalo de Guzmán,
juez susodicho, estando como están todos los pleitos e cabsas que
contra mí se tratan en grado de probanzas, por haber como ha
veinte e nueve días que los dichos pleitos penden e corren de mi
residencia, porque yo no puedo probar lo que á mi derecho conviene
sin haber fecho ni dicho cosa alguna por do pena merezca, me
tienen detenido en mi casa e á cabsa que yo parezca e quede
culpado en los dichos procesos porque pido e requiero al dicho señor
Gonzalo de Guzmán una e dos e más veces según desuso es
derecho, pues yo no he hecho cosa por do merezca estar preso
mayormente, pues no se ha fecho cosa por donde merezca muerte
ni perdimiento de miembro especialmente, pues estoy en residencia
e como tal juez que fago residencia debo de gozar e gozo de todas
las preminencias e libertades que á los susodichos son dadas e
otorgadas mayormente, pues soy notorio fijo de hidalgo, según que
es muy público e manifiesto, e siendo como soy Licenciado e
graduado por examen público, por lo cual ansimesmo debo de gozar
e gozo de todas e cualesquier preminencias e libertades que á los
susodichos son otorgadas, que su merced no añada agravio á
agravio ó fuerza á fuerza, antes me dé lugar á que yo salga de la
dicha carcelería que me tiene puesta para que yo atienda á mis
pleitos e alegue de mi derecho por manera que se parezca la verdad
e yo pueda mostrar mi inocencia e descargos, e quel dicho señor
Gonzalo de Guzmán guarde e faga guardar todas las preminencias
que en la dicha residencia se me deben ansí e según e de la manera
que se me guardaban, e con el acatamiento que se me debían
guardar al tiempo que yo tenía el dicho cargo de teniente de
gobernador, porque Dios dejase quien por él así lo faga e no
consienta ni dé lugar debajo de disimulación e risa que personas que
me tienen odio e apasionadas como en los semejantes casos se
suelen hacer, pidan por escrito ó fuera dél con palabras feas, ó digan
cosas no lícitas, porque demás de hacer su merced lo que debe
conforme á derecho, excusará pasiones e enojos que de allí se
podían suceder, pues ve la manera que los susodichos oficiales e sus
allegados, por ser como son amigos e tan unidos con el dicho señor
Gonzalo de Guzmán e que todo se les ha de sufrir e desimular, por
quien cada cosa e pleito que en la dicha Abdiencia se trata fablan
con mucha pasión e aceleramiento atrayendo e induciendo ó yendo
muchas personas que piden e molestan ante vuestra merced e de
cómo lo pido e requiero al dicho señor Gonzalo de Guzmán, vos lo
pido por testimonio e á los presentes sean testigos, e pido este abto
supuesto que el proceso de la pesquisa secreta, e protesto de
ayudarme dél e deste dicho requerimiento para que todos mis
pleitos e cabsas que en grado de residencia ante su merced contra
mí se trata, e que si á cabsa destar así detenido no hiciere mi
probanza legítima e tal cual basta para probar mis desculpas e
descargos no sea á mi cargo, antes á culpa del dicho señor Gonzalo
de Guzmán. El licenciado Altamirano.

················
Interrogatorio de oficio de justicia.
Por las preguntas siguientes sean preguntados los testigos de la
pesquisa secreta de la residencia que yo, Gonzalo de Guzmán, por
mandado de Su Majestad, tomo al licenciado Altamirano, juez de
residencia e teniente de gobernador que fué en esta isla Fernandina
e sus tenientes que han seido, e á los alguaciles e regidores desta
cibdad e de las otras villas desta isla:
1.ª Primeramente sean preguntados si conoscen al dicho
licenciado Juan Altamirano e a Francisco Osorio, tenientes en esta
cibdad, e á Francisco Aceituno, e á Francisco de Agüero, alguacil
mayor, e á Juan de Almagro, otrosí alguacil, e si conoscen al tesorero
Diego Núñez de Guzmán e al licenciado Pedro de Paz e Andrés de
Duero e á Diego de Soto, vecinos desta cibdad.
2.ª Item si saben que los dichos Licenciado e tenientes en el
dicho tiempo que tovieron el cargo tovieron arancel de los derechos
quellos e sus oficiales e escribanos solian llevar, e puesto en lugar
público e de letra legible en manera que se pudiese bien leer, e si el
dicho arancel si fué guardado por el dicho licenciado Altamirano ó
alguno dellos e los sobredichos tenientes e alguaciles e escribanos,
no guardando el dicho arancel, llevaban más derechos de los
contenidos en el dicho arancel, digan e declaren lo que saben.
3.ª Item si saben que los dichos tenientes ó algunas de las
sobredichas justicias hayan gastado promesas e dádivas que se
dieron á ellos ó á sus mujeres ó hijos, de manera que de las dichas
promesas ó dádivas viniese á ellos el provecho.
4.ª Item si saben, etc., que los dichos Licenciado, tenientes e
justicias hayan tenido parcialidad con regidores ó caballeros e otras
personas, no teniendo todos igualmente en justicia, e digan e
declaren lo que cerca desto saben, e si saben quel dicho Licenciado
ha comprado e vendido e cambiado algunas cosas ó ha tenido
ganado e otras granjerías en esta isla.
5.ª Item si saben, etc., que los dichos Licenciado, tenientes e las
otras sobredichas justicias ó alguaciles hayan llevado derechos de
ejecuciones de algunos autos ú obligaciones ó consentido llevar, no
siendo pagado primero el dueño de la debda, ó habiéndose dado por
contento, ó hayan llevado más derechos de los cuales venían según
que está en costumbre desta isla de les llevar los tales derechos ó
más de lo que mandan las leyes e ordenanzas del reino.
6.ª Item si saben que los dichos Licenciado e tenientes ó las
otras justicias ó alguno dellos hayan llevado algunas penas sin ser
sentenciadas las partes e oídas en sentencia pasada en cosa juzgada
ó hayan hecho iguala por sí ó por otra persona en las dichas penas
antes de serle sentenciada como dicho es pasada en cosa juzgada.
7.ª Item si saben, etc., que los dichos Licenciado e tenientes e
alguno dellos hayan llevado parte de sentencias que condenaron á
alguna persona.
8.ª Item si saben, etc., que los dichos Licenciado, tenientes e las
otras justicias ó alguno dellos hayan llevado derechos de homecillos
en caso que no sea de muerte de homes ó mujeres, y en caso que el
culpado no merezca la pena de muerte ó si hayan llevado la pena de
la sangre antes de ser sentenciada la cabsa e lo más de lo que debía
llevar.
9.ª Item si saben, etc., que los dichos Licenciado, tenientes e
justicias ó alguno dellos hayan arrendado los derechos de
alguacilazgo ó alcaldías ó cárcel ó entregas ó mayordomías ó
escribanías ó otros oficios, que eran á ellos de proveer por respeto
de los oficios que tenían, digan e declaren lo que cerca desto saben,
ó si saben que hayan hecho conveniencias ó igualas con los
escribanos e alguaciles ó con alguno que toviese los dichos oficios.
10. Item si saben que los dichos Licenciado, tenientes e las otras
justicias ó alguno dellos hayan dejado de ejecutar las penas de las
premáticas á los que dicen mal á nuestro Señor, e si saben que
alguna vez hayan dejado de ejecutar la dicha pena por amistad ó
enemistad, e no mandando e no cumpliendo á que esté treinta días
en la cárcel e las otras penas contenidas en las dichas premáticas.
11. Item si saben que los dichos Licenciado e tenientes pusieron
diligencia cerca de las ordenanzas desta isla, haciendo guardar las
buenas ordenanzas, enmendando las que se debían enmendar e
procurando de hacer otras complideras al bien e provecho desta isla,
especialmente como los oficiales fuesen elegidos sin parcialidad,
cómo e de qué manera pusieron deligencia que en esta isla e cibdad
estuviesen bien proveidos de carne e pescado e otros
mantenimientos, poniéndoles precios razonables, e digan e declaren
lo que desto saben.
12. Item si saben quel dicho Licenciado e sus tenientes han
castigado los pecados públicos, así como amancebados e blasfemias
de Dios nuestro Señor e de su bendita Madre, e digan lo que saben.
13. Item si saben que los dichos Licenciado e tenientes e las
otras justicias hayan consentido juegos de naipes ó dados, ú otros
juegos vedados.
14. Item si saben que los dichos Licenciado, tenientes e las otras
dichas justicias hayan hecho algunas derramas sobre las dichas villas
e pueblos e villas desta isla, e quién las cobró e en qué se gastaron,
e digan e declaren lo que cerca desto saben.
15. Item si saben, etc., que los dichos tenientes e otras justicias
hayan llevado dádivas por repartimiento desta cibdad ó de alguna
villa e lugar desta isla ó si le hayan dado los dichos regidores e
consejeros desta dicha cibdad ó de otra villa ó lugar desta dicha isla.
16. Item si saben que hayan consentido los dichos Licenciado e
tenientes e las sobredichas justicias que han sido en arriendar los
propios de las cibdades e villas desta dicha isla e oficiales del
concejo del tal pueblo por sí ó por personas interpuestas, e si saben
que los regidores las hayan arrendado de manera que hayan
consentido arrendar á personas que otras no osasen ni quisiesen
sobrepujar las dichas rentas.
17. Item si saben que los dichos Licenciado e tenientes e las
otras justicias hayan puesto deligencia para que las obras públicas
desta cibdad e de las villas e lugares desta dicha isla se hicieran á
menos costa e más provecho de los concejos.
18. Item si saben que los dichos tenientes e las otras justicias
hayan hecho los procesos criminales fuera de la cárcel, e si tienen ó
han tenido arca en que se guardar los procesos para que estén
recabdo e hayan tenido libro de todos los presos que han tenido e
venido á la cárcel, en que se declarase cada uno por qué fué preso,
e por cuyo mandado e qué bienes trajo, e cómo lo soltó e por qué, e
digan e declaren lo que cerca desto saben.
19. Item si saben, etc., que los dichos Licenciado, tenientes e las
otras justicias hayan consentido á los escribanos de concejo público
ú otros cualesquier que llevasen derechos de los procesos que
antellos pasaban que pertenecian al concejo.
20. Item si saben, etc., que los sobredichos tenientes e los
sobredichos regidores hayan consentido estar en cabildo algún
regidor hablando e platicando en cosas que le tocasen e que
hobiesen de dar votos de manera que pudiesen votar libremente, ó
platicándose alguna cosa que tocase algún debdo ó amigo ó familia
de los dichos regidores, e digan e declaren lo que cerca desto saben.
21. Item si saben que los sobredichos Licenciado, tenientes e las
otras justicias sobredichas ó alguno dellos hayan condenado algunas
penas ante otros escribanos que estaban diputados para las dichas
condenaciones, e si saben que las dichas penas en que así
condenaban las gastaban en cosas de su provecho ó en otra cosa de
lo que eran aplicadas, e si saben que el escribano ante quien se
condenaban las dichas penas si han sido alguna vez negligentes, ó
de otra manera si ha dejado de manifestar otro día después de la
condenación al escribano del concejo, e si han tomado las cuentas
en fin de cada un año al escribano de concejo e al escribano ante
quien pasaban.
22. Item si saben, etc., que los tenientes e las otras justicias ó
alguno dellos han sido negligentes en castigar los testigos falsos.
23. Item si saben que los dichos tenientes e los otros alcaldes e
jueces e justicias ó alguno dellos han dejado predicar algunas bulas
sin examinar si estaban examinadas por el obispo desta isla e
diocesano desta isla.
24. Item si saben que los dichos tenientes e otras justicias ó
alguno dellos han sacado ó dejado sacar desa dicha isla para fuera
parte della algunos indios para no los volver, e otras cosas vedadas
por provisión de Su Majestad e ordenanzas desta isla.

You might also like