Optimization in Computer Science Engineering
Optimization in Computer Science Engineering
Chandravva Hebbi
Computer Science and Engineering
Mathematics for Computer Science Engineers
Introduction to Optimization
What is Optimization?
∙ Definition: Optimization is the process of finding the best possible solution to a problem
within given constraints.
∙ Objective: It involves maximizing or minimizing an objective function, such as cost, time,
efficiency, or resource utilization.
1. Decision Variables
∙ Decision variables are those that can be controlled or adjusted to achieve the optimal value of the objective function.
∙ These are the unknown quantities that need to be determined.
∙ Example: In house price prediction, the slope (β1) indicates price change per unit of square footage, and the intercept (β0)
gives the price when the square footage is zero.
Mathematics for Computer Science Engineers
Components of an Optimization Problem
2. Objective Function
∙ The objective function is what needs to be maximized or minimized.
∙ Optimization seeks input values that maximize or minimize this function; it quantifies the goal of the process.
∙ Example: For predicting house prices by square footage, the objective function can be the squared difference between the
predicted and actual prices for all houses.
3. Constraints
∙ Constraints are conditions or limitations imposed on decision variables.
∙ They can be equality constraints (variables must satisfy an equation) or inequality constraints (variables must lie within a
range).
∙ Example: A constraint may require that the slope (β1β1) is positive, enforcing that house prices increase with more square
footage.
4. Feasible Region
∙ The feasible region is the set of all possible values for decision variables that satisfy every constraint (including non-
negativity).
∙ The optimal solution must be within this region.
∙ Example: With no constraints, all possible slopes and intercepts are feasible for the regression line.
Mathematics for Computer Science Engineers
Components of an Optimization Problem
5. Feasible and Optimal Solution
∙ Feasible Solution: Any solution that meets all the constraints of the optimization problem. It may not necessarily be the best
(optimal) outcome for the objective function.
∙ Optimal Solution: The solution among all feasible solutions that maximizes or minimizes the objective function, reflecting
the best achievable outcome within the constraints.
General form:
Optimize f(x), Subjected to
Where,
A factory produces chairs and tables. Each chair gives a profit of ₹200 and each table ₹500. Producing
one chair requires 4 hours of labour and 2 kg of wood, while a table requires 6 hours and 3 kg of wood.
The factory has at most 60 hours of labour and 30 kg of wood available per week.
Formulation:
Let
x1= number of chairs,
x2= number of tables.
Objective:
Maximize profit
Z=200x1 + 500x2
Constraints:
4x1 + 6x2 ≤ 60
2x1+3x2 ≤ 30
x1,x2 ≥0
Mathematics for Computer Science Engineers
Model formulation example
A company has 3 machines that can produce two products, A and B. Machine I can run 100
hours, Machine II 80 hours, Machine III 90 hours. Each unit of A requires 2, 1, and 1 hours on
machines I, II, and III respectively. Each unit of B requires 1, 2, and 3 hours. Profit per unit of A
and B are ₹40 and ₹50 respectively.
Formulation:
Let x1 = units of A, x2 = units of B.
Objective:
Maximize Z = 40x1+ 50x2
Constraints:
2x1+x2 ≤ 100
x1 + 2x2 ≤ 80
x1 + 3x2 ≤ 90
Mathematics for Computer Science Engineers
Model formulation example
A person wants to meet daily nutritional requirements:
Formulation:
Let x1,x2 = units of food 1 and food 2.
Objective:
Minimize cost Z = 20x1 + 10x2
Constraint:
30x1 + 10x2 ≥ 60
10x1 + 20x2 ≥ 40
x ,x ≥0
Mathematics for Computer Science Engineers
Linear programming problem example
A cloud service provider has a server that can run two applications: App A and App B. The provider has the
following data:
Profit:
● App A generates a profit of $50 per instance
● App B generates a profit of $40 per instance
Resource Usage:
● Each instance of App A requires 3 units of CPU and 2 units of memory
● Each instance of App B requires 2 units of CPU and 4 units of memory
Resource Availability:
● The total available CPU is 120 units
● The total available memory is 80 units
Mathematics for Computer Science Engineers
Linear programming
Define Decision Variables:
● x1: Number of instances of App A to deploy
● x2: Number of instances of App B to deploy
● Objective Function: Maximize the total profit Z:
○ Z = 50x1 + 40x2
● Constraints: Consider the resource limitations for CPU and memory:
● CPU Constraint: 3x1 + 2x2 ≤ 120
● Memory Constraint: 2x1 + 4x2 ≤ 80.
● Non-negativity Constraints: x1 ≥ 0; x2 ≥ 0
Mathematics for Computer Science Engineers
Model Formation: More Examples
1.
Scenario: A company manufactures two products, Product A and Product B. The objective is to maximize profit, where Product A
gives a profit of $50 per unit, and Product B gives a profit of $30 per unit. However, there are constraints on resources like
labour hours and raw materials.
Objective Function: Maximize output Z = 50x1 + 30x2
Constraints: Labor: 2x1 + x2 ≤ 40
Materials: 3x1 + 2x2 ≤ 60
Non-negativity: x1, x2 ≥ 0
2.
Scenario: Task scheduling problem where tasks need to be assigned to processors, and the objective is to minimize total
computation time.
Objective Function: Minimize computation time 𝑍 = 𝑡1𝑥1 + 𝑡2𝑥2
Constraints: Processor availability: 𝑥1 + 𝑥2 ≤ 𝐴
Task dependencies: Constraints on the sequence of task execution.
Mathematics for Computer Science Engineers
Model Formation
3.
Scenario: Optimizing the production of two types of enzymes, Enzyme A and Enzyme B, in a biotech lab to maximize output. Each
enzyme requires different amounts of chemical inputs and time in a bioreactor.
Objective Function: Maximize profit Z = p1x1 + p2x2 (p1 and p2 are profit associated with each enzyme)
Constraints: Chemical Input: c1x1 + c2x2 ≤ R (resource constraint)
Reactor Time: t1x1 + t2x2 ≤ T (time constraint)
4.
Scenario: An electric grid optimization problem where we want to maximize power supply while minimizing costs. Different
power plants have different production costs and capacities.
Objective Function: Minimize cost Z = c1x1 + c2x2 (c1 and c2 are cost associated with each enzyme)
Constraints: Power Demand: x1 + x2 ≥ D
Capacity Limits: x1 ≤ C1, x2 ≤ C2
Mathematics for Computer Science Engineers
Types of Optimizations
∙ Constrained Optimization ∙ Discrete Optimization
∙ Linear Optimization ∙ Combinatorial Optimization
● Linear Programming Problems (LPP) ∙ Knapsack Problem
● Integer Programming ∙ Traveling Salesman
●Dynamic Programming Problem
∙ Non-Linear Optimization ∙ Integer Programming
● Non-Linear Integer Programming
● Non-Linear Dynamic Programming
1. Engineering Optimization Theory and Practice, Fifth Edition, Singiresu S. Rao, 2020.
THANK YOU
Chandravva Hebbi
19
Mathematics for Computer Science Engineers
Chandravva Hebbi
Computer Science and Engineering
Mathematics for Computer Science Engineers
Introduction to Optimization
What is Optimization?
∙ Definition: Optimization is the process of finding the
best possible solution to a problem within given
constraints.
∙ Objective: It involves maximizing or minimizing an
objective function, such as cost, time, efficiency, or
resource utilization.
Optimization in Computer Science
∙ Critical Role: Optimization helps improve algorithms, allocate network resources, and
maximize software performance.
∙ Example Problem — Network Routing: The goal is to determine the most efficient path for
data across a network, minimizing latency and maximizing bandwidth. Constraints such as
bandwidth limits, congestion, and maintenance costs are considered for optimal data flow.
∙ Industry Application: Cisco Systems, a leader in networking, relies heavily on network routing
optimization to ensure fast and reliable data transfer between offices.
Mathematics for Computer Science Engineers
Introduction to Optimization
Why Optimization?
∙ Efficient Resource Utilization: Ensures best use of available resources (time, money,
materials).
∙ Improved Decision-Making: Helps select the most effective solution from alternatives.
∙ Maximizing Performance: Increases speed, accuracy, output, or other performance metrics.
∙ Cost Reduction: Minimizes waste, reducing costs across processes and industries.
∙ Handling Complex Problems: Offers structured approaches for real-world challenges with
multiple constraints.
∙ Scalability: Allows solutions to scale efficiently with complexity or size.
Real-world applications of optimization:
Category Example Company Purpose of Use
Unconstraine
d Neural Network Minimizing prediction error by adjusting
Optimization Training Facebook weights without constraints
Mathematics for Computer Science Engineers
Components of an Optimization Problem
Components of an Optimization Problem
∙ Decision Variables
∙ Objective Function
∙ Constraints
∙ Feasible and Optimal Region
∙ Methods to solve the problem
1. Decision Variables
∙ Decision variables are those that can be controlled or adjusted to achieve the optimal value of the objective function.
∙ These are the unknown quantities that need to be determined.
∙ Example: In house price prediction, the slope (β1) indicates price change per unit of square footage, and the intercept (β0)
gives the price when the square footage is zero.
Mathematics for Computer Science Engineers
Components of an Optimization Problem
2. Objective Function
∙ The objective function is what needs to be maximized or minimized.
∙ Optimization seeks input values that maximize or minimize this function; it quantifies the goal of the process.
∙ Example: For predicting house prices by square footage, the objective function can be the squared difference between the
predicted and actual prices for all houses.
3. Constraints
∙ Constraints are conditions or limitations imposed on decision variables.
∙ They can be equality constraints (variables must satisfy an equation) or inequality constraints (variables must lie within a
range).
∙ Example: A constraint may require that the slope (β1β1) is positive, enforcing that house prices increase with more square
footage.
4. Feasible Region
∙ The feasible region is the set of all possible values for decision variables that satisfy every constraint (including non-
negativity).
∙ The optimal solution must be within this region.
∙ Example: With no constraints, all possible slopes and intercepts are feasible for the regression line.
Mathematics for Computer Science Engineers
Components of an Optimization Problem
5. Feasible and Optimal Solution
∙ Feasible Solution: Any solution that meets all the constraints of the optimization problem. It may not necessarily be the best
(optimal) outcome for the objective function.
∙ Optimal Solution: The solution among all feasible solutions that maximizes or minimizes the objective function, reflecting
the best achievable outcome within the constraints.
General form:
Optimize f(x), Subjected to
Where,
A factory produces chairs and tables. Each chair gives a profit of ₹200 and each table ₹500. Producing
one chair requires 4 hours of labour and 2 kg of wood, while a table requires 6 hours and 3 kg of wood.
The factory has at most 60 hours of labour and 30 kg of wood available per week.
Formulation:
Let
x1= number of chairs,
x2= number of tables.
Objective:
Maximize profit
Z=200x1 + 500x2
Constraints:
4x1 + 6x2 ≤ 60
2x1+3x2 ≤ 30
x1,x2 ≥0
Mathematics for Computer Science Engineers
Model formulation example
A company has 3 machines that can produce two products, A and B. Machine I can run 100
hours, Machine II 80 hours, Machine III 90 hours. Each unit of A requires 2, 1, and 1 hours on
machines I, II, and III respectively. Each unit of B requires 1, 2, and 3 hours. Profit per unit of A
and B are ₹40 and ₹50 respectively.
Formulation:
Let x1 = units of A, x2 = units of B.
Objective:
Maximize Z = 40x1+ 50x2
Constraints:
2x1+x2 ≤ 100
x1 + 2x2 ≤ 80
x1 + 3x2 ≤ 90
Mathematics for Computer Science Engineers
Model formulation example
A person wants to meet daily nutritional requirements:
Formulation:
Let x1,x2 = units of food 1 and food 2.
Objective:
Minimize cost Z = 20x1 + 10x2
Constraint:
30x1 + 10x2 ≥ 60
10x1 + 20x2 ≥ 40
x ,x ≥0
Mathematics for Computer Science Engineers
Types of Optimizations
∙ Constrained Optimization ∙ Discrete Optimization
∙ Linear Optimization ∙ Combinatorial Optimization
● Linear Programming Problems (LPP) ∙ Knapsack Problem
● Integer Programming ∙ Traveling Salesman
●Dynamic Programming Problem
∙ Non-Linear Optimization ∙ Integer Programming
● Non-Linear Integer Programming
● Non-Linear Dynamic Programming
A cloud service provider has a server that can run two applications: App A and App B. The provider has the
following data:
Profit:
● App A generates a profit of $50 per instance
● App B generates a profit of $40 per instance
Resource Usage:
● Each instance of App A requires 3 units of CPU and 2 units of memory
● Each instance of App B requires 2 units of CPU and 4 units of memory
Resource Availability:
● The total available CPU is 120 units
● The total available memory is 80 units
Mathematics for Computer Science Engineers
Linear programming
Define Decision Variables:
● x1: Number of instances of App A to deploy
● x2: Number of instances of App B to deploy
● Objective Function: Maximize the total profit Z:
○ Z = 50x1 + 40x2
● Constraints: Consider the resource limitations for CPU and memory:
● CPU Constraint: 3x1 + 2x2 ≤ 120
● Memory Constraint: 2x1 + 4x2 ≤ 80.
● Non-negativity Constraints: x1 ≥ 0; x2 ≥ 0
Mathematics for Computer Science Engineers
Model Formation: More Examples
1.
Scenario: A company manufactures two products, Product A and Product B. The objective is to maximize profit, where Product A
gives a profit of $50 per unit, and Product B gives a profit of $30 per unit. However, there are constraints on resources like
labour hours and raw materials.
Objective Function: Maximize output Z = 50x1 + 30x2
Constraints: Labor: 2x1 + x2 ≤ 40
Materials: 3x1 + 2x2 ≤ 60
Non-negativity: x1, x2 ≥ 0
2.
Scenario: Task scheduling problem where tasks need to be assigned to processors, and the objective is to minimize total
computation time.
Objective Function: Minimize computation time 𝑍 = 𝑡1𝑥1 + 𝑡2𝑥2
Constraints: Processor availability: 𝑥1 + 𝑥2 ≤ 𝐴
Task dependencies: Constraints on the sequence of task execution.
Mathematics for Computer Science Engineers
Model Formation
3.
Scenario: Optimizing the production of two types of enzymes, Enzyme A and Enzyme B, in a biotech lab to maximize output. Each
enzyme requires different amounts of chemical inputs and time in a bioreactor.
Objective Function: Maximize profit Z = p1x1 + p2x2 (p1 and p2 are profit associated with each enzyme)
Constraints: Chemical Input: c1x1 + c2x2 ≤ R (resource constraint)
Reactor Time: t1x1 + t2x2 ≤ T (time constraint)
4.
Scenario: An electric grid optimization problem where we want to maximize power supply while minimizing costs. Different
power plants have different production costs and capacities.
Objective Function: Minimize cost Z = c1x1 + c2x2 (c1 and c2 are cost associated with each enzyme)
Constraints: Power Demand: x1 + x2 ≥ D
Capacity Limits: x1 ≤ C1, x2 ≤ C2
Mathematics for Computer Science Engineers
References
1. Engineering Optimization Theory and Practice, Fifth Edition, Singiresu S. Rao, 2020.
THANK YOU
Chandravva Hebbi
19
Mathematics for Computer Science Engineers
Unit - 4 Constrained Optimization
Chandravva Hebbi
Computer Science and Engineering
Mathematics for Computer Science Engineers
Graphical Solution Method
Linear Programming Problem (LPP) Context:
∙ A decision maker aims to:
∙ Maximize (e.g., revenue, profit) or
∙ Minimize (e.g., costs) an objective function Z.
∙ Z depends on decision variables.
∙ Constraints impose limitations on variables using inequalities (≤, =, ≥).
∙ Variables also typically have non-negativity restrictions (≥0).
Methods to Solve Linear Programming Problem
1. Graphical Method
2. Simplex Method
Graphical Solution
Graphical solution is limited to linear programming models containing only two decision variables (can be used with three
variables but only with great difficulty).
∙ Graphical methods provide visualization of how a solution for a linear programming problem is obtained.
∙ Graphical method: Extreme-point evaluation Method (Corner point method).
Mathematics for Computer Science Engineers
Graphical Solution Method
Graphical Solution Steps
∙ Step I: Convert each inequality as equation.
∙ Step II: Plot each equation on the graph.
∙ Step III: Shade the ‘Feasible Region’. Highlight the common Feasible region.
Feasible Region: Set of all possible solutions.
∙ Step IV: Compute the coordinates of the corner points (of the feasible region). These corner points will represent the
‘Feasible Solution’.
Feasible Solution: If it satisfies all the constraints and non-negativity restrictions.
∙ Step V: Substitute the coordinates of the corner points into the objective function to see which gives the Optimal Value. That
will be the ‘Optimal Solution’.
Optimal Solution: If it optimizes (maximizes or minimizes) the objective function.
Unbounded Solution: If the value of the objective function can be increased or decreased indefinitely, such solutions are
called Unbounded solution.
Inconsistent Solution: It means the solution of problem does not exist. This is possible when there is no common feasible
region.
Mathematics for Computer Science Engineers
Graphical Method-Maximization Example-1
How many bowls and mugs should be produced to maximize profits given labour and materials constraints?
Decision Variables: Resource Bowls Mugs Availability
(Units) (Units)
x1 = number of bowls,
x2 = number of mugs. Labor 40 Hours
(Hr./Unit) 1 2 per day
Clay
Objective function: (Lb./Unit) 4 3 120 pounds
[Link] resource constraint requires that for every unit of Product 1, 4 other units of a different resource are
needed, and for every unit of Product 2, 3 units of that resource are required. The total of this resource must be
at least 24 units.
Super-gro 2 4
Crop-quick 4 3
Mathematics for Computer Science Engineers
Graphical Method-Unbounded Example
Decision Variables
∙ x1: Number of Super-gro bags to produce.
∙ x2: Number of Crop-quick bags to produce.
Objective Function
Maximize total profit:
Z = 6x1 + 3x2
Where:
∙ 6x1: Cost of Super-gro bags,
In this example, common feasible region does not exist and
∙ 3x2: Cost of Crop-quick bags. hence the problem is not having an optimal solution. This is
Constraints the case of infeasible solution.
∙ Nitrogen: 3x1 + x2 ≥ 8
∙ Phosphate: x1+x2 ≥ 5
∙ Non-negativity: x1 ≥ 0, x2 ≥ 0
Mathematics for Computer Science Engineers
Graphical Method-Infeasible Solution Example
Simplex Method
for solving LPP
Mathematics for Computer Science Engineers
Simplex Method Example 1
Example Problem
A forestry company manages two types of tree plantations: pine and eucalypt.
● Each hectare of pine yields a profit of $90.
3. Due to limitations in labour and water availability, the total resource usage must not exceed a limit.
Solution:
Initial Simplex Table (canonical form)
Interpretation: basic variables are S1, S2, S3 (their RHS values are the initial basic solution). Objective row shows
negative coefficients under x1, x2 so we can improve Z.
Mathematics for Computer Science Engineers
Simplex Method Example 1
Step 1 — Choose entering variable and leaving variable
∙ Entering variable: pick the most negative coefficient in the Z-row. Here −120 (under x2) is more negative than −90, so x2
enters.
∙ Leaving variable: do the ratio test for rows where x2 coefficient > 0:
o S1 row: coefficient 0 → not eligible
o S2 row: coefficient 1 → ratio = RHS / coeff = 50/1 = 50
o S3 row: coefficient 3 → ratio = 180/3=60
o Minimum ratio = 50 → S2 leaves. Pivot element = 1 (row S2, col x2).
Row operations (pivot at row S2, column x2 — pivot = 1)
∙ Pivot row (S2) already has 1 in x2, so no scaling required.
∙ Eliminate x2 in other rows:
RZ := RZ + 120 * RS2
RS1 := RS1 (no change, x2 coeff = 0)
RS3 := RS3 - 3 * RS2
Mathematics for Computer Science Engineers
Simplex Method Example 1
Compute the numbers:
∙ RZ new:
Z-row new = [1, -90 + 120 x 0, -12 x 0 + 120 x 1, 0 + 120 x 0, 0 + 120 x 1, 0 + 120 x 0 | 0 + 120 x 50]
= [1, -90, 0, 0, 120, 0 | 6000]
∙ RS3 new = RS3 − 3RS2:
= [0, 2 – 3 x 0, 3 – 3 x 1, 0 – 3 x 0, 0 – 3 x 1, 1 – 3 x 0 | 180 – 3 x 50]
= [0, 2, 0, 0, -3, 1 | 30]
So, the table becomes:
Basic Var. Z x₁ x₂ S₁ S₂ S₃ RHS
Z 1 -90 0 0 120 0 6000
S1 0 1 0 1 0 0 40
x2 0 0 1 0 1 0 50
S3 0 2 0 0 -3 1 30
Remarks: x2 replaced S2 in basis (row label now x2). Z improved from 0 to Z=6000 (RHS of Z-row).
Mathematics for Computer Science Engineers
Simplex Method Example 1
Step 2 — Next pivot
∙ Look at Z-row: coefficients under decision variables: x1 column = −90 (still negative) and x2 column = 0. So x1 should enter
next.
∙ Ratio test for x1 (rows where coefficient > 0):
o S1 row: coeff of x1 = 1 → ratio = 40/1=40
o x2 row: coeff = 0 → not eligible
o S3 row: coeff = 2 → ratio = 30/2=15
o Minimum ratio = 15 → S3 leaves. Pivot element = 2 (row S3, col x1).
Row operations (pivot at S3 row, x1 column)
1. Scale pivot row to make pivot = 1:
RS3 :=RS3/2
So new pivot row (becomes x1 row after pivot):
Rx1 = [0, 1, 0, 0, −3/2, 1/2 ∣ 15]
(i.e. S3/2)
Mathematics for Computer Science Engineers
Simplex Method Example 1
2. Eliminate x1 from other rows:
RZ := RZ + 90 * Rx1
RS1:= RS1 - 1 * Rx1
Rx2:= Rx2 (x1 coeff is zero here, no change)
Compute the numbers exactly:
∙ New RZ:
previous RZ = [1, -90, 0, 0, 120, 0 | 6000]
add 90×Rx1 = [0,90,0,0, −135,45∣1350]
→ RZ new = [1, 0, 0, 0, -15, 45 | 7350]
∙ New RS1:
previous RS1 = [0, 1, 0, 1, 0, 0 | 40]
subtract Rx1 = [0, 1, 0, 0, -3/2, 1/2 | 15]
→ RS1 new = [0, 0, 0, 1, 3/2, -1/2 | 25]
∙ Rx2 remains [0, 0, 1, 0, 1, 0 | 50].
Mathematics for Computer Science Engineers
Simplex Method Example 1
So, the table after the second pivot is:
Basic Var. Z x₁ x₂ S₁ S₂ S₃ RHS
Z 1 0 0 0 -15 45 7350
S1 0 0 0 1 3/2 -1/2 25
x2 0 0 1 0 1 0 50
x1 0 1 0 0 -3/2 1/2 15
Iteration 3
● Check for negative coefficients in Z-row: The rule for the simplex method is to continue as long as there is a negative coefficient in the
objective row, for any non-basic variable.
● Here, S₂ (a slack variable) has a negative coefficient (–15). If we want to drive all slack variables to 0 in the objective row for the
highest Z, and strictly apply the simplex method, S₂ should enter the basis.
Mathematics for Computer Science Engineers
Simplex Method Example 1
● S₁: 0+15×(2/3)=10
● S₂: −15+15×1=0
● S₃: 45+15×(−1/3)=45−5=40
● RHS: 7350+15×16.6667=7600
So Z row becomes:
| Z | 1 | 0 | 0 | 10 | 0 | 40 | 7600 |
x₂-row: Current
x₂ row update: x₂_new = x₂_old - 1 × (new S₂ row) (since S₂ coefficient in x₂ row = 1)
Each entry:
● S₁: 0−(2/3)=−2/3
● S₂:1−1=0
● S₃: 0−(−1/3)=1/3
● RHS: 50−16.6667=33.3333
So x₂ row:
| x₂ | 0 | 0 | 1 | -2/3 | 0 | 1/3 | 33.3333 |
Mathematics for Computer Science Engineers
Simplex Method Example 1
∙ S₂ = 16.67
x2 0 1 −2/3 0 1/3 33.33
Objective value: Zmax=7600
x1 1 0 1 0 0 40
Check: Z = 90(40) +120(33.33) =3600+3999.6 = 7600.
Check constraints:
∙ x1 = 40 ≤ 40
∙ x2 = 33.33 ≤ 50
∙ 2(40) + 3(33.33) = 80+99.99 = 180
∙ Remaining land by constraint 2: S₂=16.67, (so x₂ does not fully exhaust land limit).
1. Due to a shortage of high-quality wood, the factory can produce at most 30 tables.
2. Because of the limited number of metal frames, chair production cannot exceed 40 units.
3. The total workshop capacity (labour hours, machine time, and finishing space) restricts overall production — producing
○ 1 table uses 1 capacity unit,
○ 1 chair uses 2 capacity units, and
○ 1 cabinet uses 1 capacity unit, and the total capacity available is 100 units.
The company wants to determine how many tables (x₁), chairs (x₂), and cabinets (x₃) to produce in order to maximize total
profit.
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Simplex Method Example 2
Mathematics for Computer Science Engineers
Odd cases in Simplex method
[Link] for the Entering Basic Variable (BV)
∙ In a maximization problem, the entering variable is the non-basic variable (NBV) with the most negative coefficient in Z row
(objective function row).
∙ Sometimes, in the very initial table or after a few iterations, two or more NBVs have the same most negative coefficient →
tie.
∙ In this case, we can choose any of them arbitrarily as the entering variable.
Example:
Maximize: Z = 5x1 + 5x2
Subject to: BV x₁ x₂ s₁ s₂ RHS
Z -5 -5 0 0 0
∙ x1 + x 2 ≤ 4
x1 1 1 1 0 4
∙ 2x1 + x2 ≤ 5
∙ x1 , x 2 ≥ 0 x2 2 1 0 1 5
Process Total Hours Available Hours per Unit Product A Hours per Unit Product B Hours per Unit Product C
I 12,000 5 2 4
II 24,000 4 5 6
III 18,000 3 5 4
Assuming the selling profits for products A, B and C are 2, 3 and 4€ per unit. Determine how many units of each product should
be produced to maximize the profit. Was there any time left?
Mathematics for Computer Science Engineers
Other problems to solve
2.
A company produces 3 different bookshelves: a luxury, a regular and an exportation model. Consider the maximum demand for
each model to be 500, 750 and 400 respectively. The working hours at the carpentry and finishing sections have the working
time limitations
Assuming the selling profit for the luxury, regular and exportation models is 1500, 1300 2500 respectively, formulate the LP
problem in order to maximize the profit. Interpret the results detailing the optimal number of bookshelves of each type
produced discussing the total amount of hours used in each section. How far from meeting the maximum demands were we?
Section Total Hours Available Hours per Unit Luxury Hours per Unit Regular Hours per Unit
(thousands) Exportation
Carpentry 1.4 0.5 0.5 1.0
Finishing 1.2 0.5 0.5 2.0
Mathematics for Computer Science Engineers
Other problems to solve
6.
3.
Max: Z = - x2
Max: Z = x1 + 2x2
Subject to: x1 + x2 + x3 ≤ 100
Subject to: 2x1 + 4x2 ≤ 20
x1 - 5x2 ≤ 40
x1 + x2 ≤ 8 and x1, x2 ≥ 0
x3 ≥ -10 and x1, x2, x3 ≥ 0
4.
7.
Max: Z = x1 + x2
Min: Z = 2x1 - 3x2 – 4x3
Subject to: x1 + x2 ≤ 4
Subject to: x1 + 5x2 - 3x3 ≤ 15
2x1 + x2 ≤ 6
x1 + x2 + x3 ≤ 11
x1 + 2x2 ≤ 6 and x1 x2 ≥ 0
5x1 – 6x2 + x3 ≤ 4 and x1, x2, x3 ≥ 0
5.
8.
Max: Z = x1 + x2
Max: Z = 10x1 + 30x2
Subject to: x1 + x2 ≤ 10
Subject to: x1 ≤ 15
2x1 - 3x2 ≤ 15
x1 - x2 ≤ 20
x1 - 2x2 ≤ 20 and x1 x2 ≥ 0
-3x1 + x2 ≤ -30 and x1, x2 ≥ 0
Mathematics for Computer Science Engineers
References
1. Engineering Optimization Theory and Practice, Fifth Edition, Singiresu S. Rao, 2020.
THANK YOU
Chandravva Hebbi
52
Mathematics for Computer Science Engineers
Unit - 4 Constrained Optimization
Mathematics for Computer Science Engineers
Model Formation
1.
Scenario: A company manufactures two products, Product A and Product B. The objective is to maximize profit, where Product A
gives a profit of $50 per unit, and Product B gives a profit of $30 per unit. However, there are constraints on resources like
labour hours and raw materials.
Constraints: Labor: 2x1 + x2 ≤ 40
Materials: 3x1 + 2x2 ≤ 60
Non-negativity: x1, x2 ≥ 0
Objective Function: Maximize output Z = p1x1 + p2x2
2.
Scenario: Task scheduling problem where tasks need to be assigned to processors, and the objective is to minimize total
computation time.
Objective Function: Minimize computation time 𝑍 = 𝑡1𝑥1 + 𝑡2𝑥2
Constraints: Processor availability: 𝑥1 + 𝑥2 ≤ 𝐴
Task dependencies: Constraints on the sequence of task execution.
Mathematics for Computer Science Engineers
Model Formation
3.
Scenario: Optimizing the production of two types of enzymes, Enzyme A and Enzyme B, in a biotech lab to maximize output. Each
enzyme requires different amounts of chemical inputs and time in a bioreactor.
Objective Function: Maximize profit Z = p1x1 + 30x2
Constraints: Chemical Input: c1x1 + c2x2 ≤ R (resource constraint)
Reactor Time: t1x1 + t2x2 ≤ T (time constraint)
4.
Scenario: An electric grid optimization problem where we want to maximize power supply while minimizing costs. Different
power plants have different production costs and capacities.
Objective Function: Minimize cost Z = c1x1 + c2x2
Constraints: Power Demand: x1 + x2 ≥ D
Capacity Limits: x1 ≤ C1, x2 ≤ C2
Mathematics for Computer Science Engineers
Graphical Solution Method
Linear Programming Problem (LPP) Context:
∙ A decision maker aims to:
∙ Maximize (e.g., revenue, profit) or
∙ Minimize (e.g., costs) an objective function Z.
∙ Z depends on decision variables.
∙ Constraints impose limitations on variables using inequalities (≤, =, ≥).
∙ Variables also typically have non-negativity restrictions (≥0).
Methods to Solve Linear Programming Problem
1. Graphical Method
2. Simplex Method
Graphical Solution
Graphical solution is limited to linear programming models containing only two decision variables (can be used with three
variables but only with great difficulty).
∙ Graphical methods provide visualization of how a solution for a linear programming problem is obtained.
∙ Graphical method: Extreme-point evaluation Method (Corner point method).
Mathematics for Computer Science Engineers
Graphical Solution Method
Graphical Solution Steps
∙ Step I: Convert each inequality as equation.
∙ Step II: Plot each equation on the graph.
∙ Step III: Shade the ‘Feasible Region’. Highlight the common Feasible region.
Feasible Region: Set of all possible solutions.
∙ Step IV: Compute the coordinates of the corner points (of the feasible region). These corner points will represent the
‘Feasible Solution’.
Feasible Solution: If it satisfies all the constraints and non-negativity restrictions.
∙ Step V: Substitute the coordinates of the corner points into the objective function to see which gives the Optimal Value. That
will be the ‘Optimal Solution’.
Optimal Solution: If it optimizes (maximizes or minimizes) the objective function.
Unbounded Solution: If the value of the objective function can be increased or decreased indefinitely, such solutions are
called Unbounded solution.
Inconsistent Solution: It means the solution of problem does not exist. This is possible when there is no common feasible
region.
Mathematics for Computer Science Engineers
Graphical Method-Maximization Example
Example 1
How many bowls and mugs should be produced to maximize profits given labour and materials constraints?
Resource Bowls Mugs Availability
(Units) (Units)
Labor 40 Hours
(Hr./Unit) 1 2 per day
Clay
∙ Decision Variables: (Lb./Unit) 4 3 120 pounds
x1 = number of bowls, Profit Objective:
x2 = number of mugs. ($/Unit) 40 50 Maximize Z
∙ Objective function:
Maximize Z = 40x1 + 50x2
∙ Constraints:
∙ x1 + 2x2 ≤ 40(labour hours constraint)
∙ 4x1 + 3x2 ≤ 120 (clay constraint)
∙ x1 ≥ 0, x2 ≥ 0(non-negativity)
Super-gro 2 4
Crop-quick 4 3
Constraints
∙ Nitrogen: 2x1 + 4x2 ≥ 16
∙ Phosphate: 4x1+3x2 ≥ 24
∙ Non-negativity: x1 ≥ 0, x2 ≥ 0
Mathematics for Computer Science Engineers
Simplex Method
Note: The graphical approach can be used for two-variable LP problems Unfortunately, most real-life LPs problems require a
method to find optimal solutions capable of dealing with several variables: the simplex algorithm
Example Problem
Maximize objective function: Z=90x1 + 120x2
where:
∙ x1: hectares of pine,
∙ x2: hectares of eucalypt.
Subject to constraints:
• x1 ≤ 40
• x2 ≤ 50
• 2x1 + 3x2 ≤ 180
• x1, x2 ≥ 0
Mathematics for Computer Science Engineers
Simplex Method
Solution:
Introduce slack variables S1, S2, S3 for the three “≤” constraints. The equations become
∙ x1 + S1 = 40
∙ x2 + S2 = 50
∙ 2x1 + 3x2 + S3 = 180
Objective as equation: Z − 90x1 − 120x2 = 0
Initial Simplex Table (canonical form)
Columns: [Z, x1, x2, S1, S2, S3 ∣ RHS]
Basic Var. Z x₁ x₂ S₁ S₂ S₃ RHS
Z 1 -90 -120 0 0 0 0
S1 0 1 0 1 0 0 40
S2 0 0 1 0 1 0 50
S3 0 2 3 0 0 1 180
Interpretation: basic variables are S1, S2, S3 (their RHS values are the initial basic solution). Objective row shows negative
coefficients under x1, x2 so we can improve Z.
Mathematics for Computer Science Engineers
Simplex Method
Step 1 — Choose entering variable and leaving variable
∙ Entering variable: pick the most negative coefficient in the Z-row. Here −120 (under x2) is more negative than −90, so x2
enters.
∙ Leaving variable: do the ratio test for rows where x2 coefficient > 0:
o S1 row: coefficient 0 → not eligible
o S2 row: coefficient 1 → ratio = RHS / coeff = 50/1 = 50
o S3 row: coefficient 3 → ratio = 180/3=60
o Minimum ratio = 50 → S2 leaves. Pivot element = 1 (row S2, col x2).
Row operations (pivot at row S2, column x2 — pivot = 1)
∙ Pivot row (S2) already has 1 in x2, so no scaling required.
∙ Eliminate x2 in other rows:
RZ := RZ + 120 * RS2
RS1 := RS1 (no change, x2 coeff = 0)
RS3 := RS3 - 3 * RS2
Mathematics for Computer Science Engineers
Simplex Method
Compute the numbers:
∙ RZ new:
Z-row new = [1, -90 + 1200, -120 + 1201, 0 + 1200, 0 + 1201, 0 + 1200 | 0 + 12050]
= [1, -90, 0, 0, 120, 0 | 6000]
∙ RS3 new = RS3 − 3RS2:
= [0, 2 - 30, 3 - 31, 0 - 30, 0 - 31, 1 - 30 | 180 - 350]
= [0, 2, 0, 0, -3, 1 | 30]
So, the table becomes:
Basic Var. Z x₁ x₂ S₁ S₂ S₃ RHS
Z 1 -90 0 0 120 0 6000
S1 0 1 0 1 0 0 40
x2 0 0 1 0 1 0 50
S3 0 2 0 0 -3 1 30
Remarks: x2 replaced S2 in basis (row label now x2). Z improved from 0 to Z=6000 (RHS of Z-row).
Mathematics for Computer Science Engineers
Simplex Method
Step 2 — Next pivot
∙ Look at Z-row: coefficients under decision variables: x1 column = −90 (still negative) and x2 column = 0. So x1 should enter
next.
∙ Ratio test for x1 (rows where coefficient > 0):
o S1 row: coeff of x1 = 1 → ratio = 40/1=40
o x2 row: coeff = 0 → not eligible
o S3 row: coeff = 2 → ratio = 30/2=15
o Minimum ratio = 15 → S3 leaves. Pivot element = 2 (row S3, col x1).
Row operations (pivot at S3 row, x1 column)
1. Scale pivot row to make pivot = 1:
RS3 :=RS3/2
So new pivot row (becomes x1 row after pivot):
Rx1 = [0, 1, 0, 0, −3/2, 1/2 ∣ 15]
(i.e. S3/2)
Mathematics for Computer Science Engineers
Simplex Method
2. Eliminate x1 from other rows:
RZ := RZ + 90 * Rx1
RS1:= RS1 - 1 * Rx1
Rx2:= Rx2 (x1 coeff is zero here, no change)
Compute the numbers exactly:
∙ New RZ:
previous RZ = [1, -90, 0, 0, 120, 0 | 6000]
add 90×Rx1 = [0,90,0,0, −135,45∣1350]
→ RZ new = [1, 0, 0, 0, -15, 45 | 7350]
∙ New RS1:
previous RS1 = [0, 1, 0, 1, 0, 0 | 40]
subtract Rx1 = [0, 1, 0, 0, -3/2, 1/2 | 15]
→ RS1 new = [0, 0, 0, 1, 3/2, -1/2 | 25]
∙ Rx2 remains [0, 0, 1, 0, 1, 0 | 50].
Mathematics for Computer Science Engineers
Simplex Method
So, the table after the second pivot is:
Basic Var. Z x₁ x₂ S₁ S₂ S₃ RHS
Z 1 0 0 0 -15 45 7350
S1 0 0 0 1 3/2 -1/2 25
x2 0 0 1 0 1 0 50
x1 0 1 0 0 -3/2 1/2 15
Example:
Maximize: Z = 3x1 + 5x2
Subject to:
∙ x1 + x2 ≤ 4x
∙ 2x1 + x2 ≤ 5
∙ x1 , x 2 ≥ 0
Mathematics for Computer Science Engineers
Odd cases in Simplex method
Step 1: Convert to Standard Form
Add slack variables s1, s2 :
x1 + x2 + s1=4
2x1 + x2 + s2 = 5
Initial Simplex Table:
BV x₁ x₂ s₁ s₂ RHS
s₁ 1 1 1 0 4
s₂ 2 1 0 1 5
Z -3 -5 0 0 0
BV x₁ x₂ s₁ s₂ RHS
s₁ 1 1 1 0 4
s₂ 2 2 0 1 8
Z -3 -3 0 0 0
Process Total Hours Available Hours per Unit Product A Hours per Unit Product B Hours per Unit Product C
I 12,000 5 2 4
II 24,000 4 5 6
III 18,000 3 5 4
Assuming the selling profits for products A, B and C are 2, 3 and 4€ per unit. Determine how many units of each product should
be produced to maximize the profit. Was there any time left?
Mathematics for Computer Science Engineers
Other problems to solve
2.
A company produces 3 different bookshelves: a luxury, a regular and an exportation model. Consider the maximum demand for
each model to be 500, 750 and 400 respectively. The working hours at the carpentry and finishing sections have the working
time limitations
Assuming the selling profit for the luxury, regular and exportation models is 1500, 1300 2500 respectively, formulate the LP
problem in order to maximize the profit. Interpret the results detailing the optimal number of bookshelves of each type
produced discussing the total amount of hours used in each section. How far from meeting the maximum demands were we?
Section Total Hours Available Hours per Unit Luxury Hours per Unit Regular Hours per Unit
(thousands) Exportation
Carpentry 1.4 0.5 0.5 1.0
Finishing 1.2 0.5 0.5 2.0
Mathematics for Computer Science Engineers
Other problems to solve
8.
3.
Max: Z = - x2
Max: Z = x1 + 2x2
Subject to: x1 + x2 + x3 ≤ 100
Subject to: 2x1 + 4x2 ≤ 20
x1 - 5x2 ≤ 40
x1 + x2 ≤ 8 and x1, x2 ≥ 0
x3 ≥ -10 and x1 ≥ 0, x2 ≤ 0, x3 unbounded
4.
6.
Max: Z = x1 + x2
Min: Z = 2x1 - 3x2 – 4x3
Subject to: x1 + x2 ≤ 4
Subject to: x1 + 5x2 - 3x3 ≤ 15
2x1 + x2 ≤ 6
x1 + x2 + x3 ≤ 11
x1 + 2x2 ≤ 6 and x1 x2 ≥ 0
5x1 – 6x2 + x3 ≤ 4 and x1, x2, x3 ≥ 0
5.
7.
Max: Z = x1 + x2
Max: Z = 10x1 + 30x2
Subject to: x1 + x2 ≤ 10
Subject to: x1 ≤ 15
2x1 - 3x2 ≤ 15
x1 - x2 ≤ 20
x1 - 2x2 ≤ 20 and x1 x2 ≥ 0
-3x1 + x2 ≤ -30 and x1 ≥ 0 x2 ≤ 0
Mathematics for Computer Science Engineers
References
1. Engineering Optimization Theory and Practice, Fourth Edition, Singiresu S. Rao, 2009.
THANK YOU
29
Mathematics for Computer Science Engineers
Unit - 4 Discrete variable optimization
Chandravva Hebbi
Computer Science and Engineering
Mathematics for Computer Science Engineers
Discrete variable optimization
Discrete Variable Optimization involves finding the best solution where decision variables can only take discrete values. These
values are often integers or specific finite choices.
Types of Discrete Variable Optimization
1. Combinatorial Optimization
∙ Focuses on finding the best combination of discrete objects chosen from a finite set. Eg. Traveling Salesman Problem,
Knapsack Problem
2. Integer Programming (IP)
∙ Optimization where some or all variables are restricted to integer values.
∙ Important in problems where quantities cannot be fractional like number of machines, workers, or batches.
Note:
• Similar to Linear Programming models but with integer restrictions on decision variables.
• The restrictions ensure solutions are realistic (e.g., you cannot purchase a fraction of a machine).
Types of Integer Programming Models:
∙ Total Integer Model: All decision variables are integers.(Similar to Linear Programming models but with integer restrictions on decision variables)
∙ 0-1 Integer Model: All decision variables are binary; values are either 0 or 1 (commonly used for yes/no decisions).
∙ Mixed Integer Model: Some variables are integers, others can be continuous/real numbers.
Mathematics for Computer Science Engineers
Total Integer Problem Formulation
Press machine increases profit by $100, Lathe machine increases profit by $150
Price and floor space:
∙ Press: $8,000 and 15 sq ft space
∙ Lathe: $4,000 and 30 sq ft space
Budget: $40,000
Floor space: 200 sq ft
Goal: Maximize profit by deciding how many presses and lathes to purchase.
Problem Formulation:
x1 = number of press machines (integer, ≥ 0) , x2 = number of lathe machines (integer, ≥ 0)
Objective Function:
Maximize Z=100x1 + 150x2
Constraints:
8000x1 + 4000x2 ≤ 40000 (Budget constraint) , 15x1 + 30x2 ≤ 200 (Floor space constraint)
Variable restrictions:
x1, x2 ≥ 0, both integers x1, x2 ≥ 0, both integers
Mathematics for Computer Science Engineers
0-1 Integer Model Example
Problem Context:
•Research and Development (R&D) program with 4 projects: A, B, C, and D.
•Constraints on the number of Operations Research (OR) specialists and budget.
•Expected profit, cost, and specialist requirements vary per project.
•Special condition: Only project A or project B can be chosen, not both.
Key Elements:
Decision Variables:
•Binary variables xi ∈ {0,1} for each project i, where 1 means selecting the project, 0 means not selecting.
Constraints:
•Budget constraints based on project costs.
•Specialist availability constraints.
•Mutually exclusive project selection for projects A and B.
Mathematics for Computer Science Engineers
0-1 Integer Model Example
Problem Setup:
∙ Four research projects: A, B, C, and D
∙ Each project has expected profit, cost, and resource requirements
∙ Projects can either be selected (1) or not selected (0)
∙ Special constraint: Projects A and B are mutually exclusive (only one can be chosen)
Model Formulation:
Decision Variables:
∙ A, B, C, D ∈ {0, 1} where:
∙ A = 1 if project A is selected, 0 otherwise
∙ B = 1 if project B is selected, 0 otherwise
∙ C = 1 if project C is selected, 0 otherwise
D = 1 if project D is selected, 0 otherwise
Mathematics for Computer Science Engineers
0-1 Integer Model Example
Objective Function:
Maximize Z=300A + 90B + 400C + 150D
Constraints:
1. Budget constraint:
35,000A + 10,000B + 25,000C + 90,000D ≤ 120,000
2. OR Specialists constraint:
4A + 2B + 7C + 3D ≤ 12
Mutually exclusive projects:
A+B=1
This ensures either A or B is selected, but not both.
3. Binary restrictions:
A, B, C, D ∈ {0,1}
Key Insight:
The constraint A + B = 1 means exactly one of projects A or B must be chosen. This would result in solutions like A = 1, B = 0 or A
= 0, B = 1, but never both equal to 1.
Mathematics for Computer Science Engineers
Mixed Integer Model
Problem Description:
∙ Budget: $500,000 to invest in townhouses and land
∙ Returns: $8,000 per townhouse, $6,000 per acre of land
∙ Costs: Townhouse = $70,000, Land = $30,000 per acre
∙ Maintenance: $1,000 per townhouse, $2,000 per acre annually
∙ Maintenance budget: $14,000
∙ Goal: Maximize annual return
Decision Variables:
∙ x1 = number of townhouses (must be integer)
∙ x2 = acres of land (can be fractional)
Mathematics for Computer Science Engineers
Mixed Integer Model
Model Formulation:
Objective Function:
Maximize Z = 8000x1 + 6000x2
Constraints:
1. Investment budget:
70,000x1 + 30,000x2 ≤ 500,000
1. Maintenance budget:
1000x1 + 2000x2 ≤ 14,000
Variable Restrictions:
∙ x1 ≥ 0 and integer (townhouses must be whole units)
∙ x2 ≥ 0 (land can be fractional acres)
Key Features:
∙ Mixed nature: One variable must be integer, the other can be continuous
∙ Real-world logic: You can't build half a townhouse, but you can buy fractional acres
Mathematics for Computer Science Engineers
Integer Programming Solution Issues
The Rounding Problem:
Example from Machine Purchase Problem:
∙ LP solution: x1 = 2.22, x2 = 5.55
∙ Rounded solution: x1 = 2, x2 = 6
Problem: When substituting rounded values back into constraints:
∙ Original constraint: 15x1 + 30x2 ≤ 200
∙ Check: 15(2) + 30(6) = 30+180 = 210 > 200
∙ Result: Constraint is violated → Infeasible solution
Why Rounding Fails:
∙ Rounding may violate budget, space, or resource constraints
∙ The optimal integer solution may be far from the LP solution
∙ Need specialized integer programming algorithms like Branch-and-Bound
Mathematics for Computer Science Engineers
Branch-and-Bound Method for Integer Programming
Concept Overview:
∙ Branch-and-bound is a systematic algorithm to solve integer programming problems by dividing the problem
into smaller subproblems.
∙ Branch: Refers to constructing a tree structure where each node represents a subproblem with some variables
restricted.
∙ Bound: Uses an estimate of the objective function (a bound) to prune subproblems that cannot yield better
solutions than the current best.
∙ This approach avoids exhaustive search by ignoring infeasible or suboptimal branches early.
Mathematics for Computer Science Engineers
Branch-and-Bound Method for Integer Programming
When to Stop Branching or Prune?
1. When an integer feasible solution is found.
2. When a node is infeasible.
3. When further branching cannot improve objective z:
∙ For minimization, no potential for a lower z
∙ For maximization, no potential for a higher z
Note: Branch and Bound Method is applicable for any number of variables.
Branch-and-Bound Process Steps:
1. Start with the LP relaxation of the integer problem (ignore integrality).
2. If the LP solution is integer, it is optimal—stop.
3. Otherwise, select a variable with a fractional value and create two branches:
∙ One branch with the variable rounded down.
∙ Another with the variable rounded up.
4. Solve subproblems recursively, calculating bounds.
5. Prune branches where bounds show no improvement over the best-found solution.
6. Continue until all branches are either solved or pruned.
Mathematics for Computer Science Engineers
Branch-and-Bound Examples
Example:
Decision variables: x = [x1, x2]
• x1 ∈ {0,1,2,3,4,5,6,7,8}
• x2 ∈ {0,1,2,3,4,5}
Maximize, z=3x1+5x2
Constraints:
2x1+4x2≤ 25
x1 ≤ 8 and 2x2 ≤ 10
Determine: x, c, A, b
Step 1:
Relax the Integer Constraints
• Initially, ignore the integer restrictions on x1 and x2.
• Solve the relaxed linear optimization problem allowing x1, x2
to be any real (continuous) values.
Key Observations
∙ This example was solved quickly with just one level of branching.
∙ Because of the immediate integer feasible solution, no pruning occurred in this case.
∙ The value z=35.25 from the relaxed problem is an upper bound on the maximum integer solution achievable.
Mathematics for Computer Science Engineers
Branch and Bound Example
Example 2
Problem Setup
∙ Maximize: z = 5x1 + 4x2
∙ Subject to: x1 + x2 ≤ 5x1 + x2 ≤ 5 and 10x1 + 6x2 ≤ 45
Decision variables x1, x2 can only take positive integer values.
•All the examples discussed above have 2 design variables, x1, and x2.
•Brach and Bound Method is applicable for any number of variables.
•We discussed 2 variable problems, because such problems can be solved within a limited amount of
time using pen and paper.
•We also carefully chose problems, which are linear and have global optimum.
Mathematics for Computer Science Engineers
Problems to practice
Example 4: Maximize z = -x1 + 4x2 such that -10x1 + 20x2 ≤ 22, 5x1 + 10x2≤ 49, and x1 ≤ 10 where x, the design variables, can only
take positive integer values. Determine x, c, A, b. Solve x = [x1, x2]. The design variables are x1 and x2.
[Solution: (X1, X2) = (2,2), z = 6]
Example 5: Maximize z = x1 + 4x2 such that 2x1 + 4x2 ≤ 7, 5x1 + 3x2 ≤ 15, where x, the design variables, can only take positive
integer values. • Determine x, c, A, b. Solve x = [x1, x2]. The design variables are x1 and x2.
[Solution: (X1, X2) = (1,1), z = 5]
Example 6: Maximize z = 5x1 + 6x2 such that x1 + x2 ≤ 5 and, x1 + 7x2 ≤ 28 where x, the design variables, can only take positive
integer values. Determine x, c, A, b. Solve x = [x1, x2]. The design variables are x1 and x2.
[Solution: (X1, X2) = (2,3), z = 28]
Example 7: Maximize z = 5x1 + 8x2 such that 5x1 + 9x2 ≤ 45 and, x1 + x2 ≤ 6 where x, the design variables, can only take positive
integer values. Determine x, c, A, b. Solve x = [x1, x2]. The design variables are x1 and x2.
[Solution: (X1, X2) = (0,5), z = 40]
Mathematics for Computer Science Engineers
References
1. Engineering Optimization Theory and Practice, Fifth Edition, Singiresu S. Rao, 2020.
THANK YOU
Chandravva Hebbi
22
Mathematics for Computer Science Engineers
Unit - 4 Discrete variable optimization
Chandravva Hebbi
Computer Science and Engineering
Mathematics for Computer Science Engineers
Discrete variable optimization
Discrete Variable Optimization involves finding the best solution where decision variables can only take discrete values. These
values are often integers or specific finite choices.
Types of Discrete Variable Optimization
1. Combinatorial Optimization
∙ Focuses on finding the best combination of discrete objects chosen from a finite set. Eg. Traveling Salesman Problem,
Knapsack Problem
2. Integer Programming (IP)
∙ Optimization where some or all variables are restricted to integer values.
∙ Important in problems where quantities cannot be fractional like number of machines, workers, or batches.
Note:
• Similar to Linear Programming models but with integer restrictions on decision variables.
• The restrictions ensure solutions are realistic (e.g., you cannot purchase a fraction of a machine).
Types of Integer Programming Models:
∙ Total Integer Model: All decision variables are integers.(Similar to Linear Programming models but with integer restrictions on decision variables)
∙ 0-1 Integer Model: All decision variables are binary; values are either 0 or 1 (commonly used for yes/no decisions).
∙ Mixed Integer Model: Some variables are integers, others can be continuous/real numbers.
Mathematics for Computer Science Engineers
Total Integer Problem Formulation
A small workshop is expanding its production capacity by purchasing new machines. Each press
machine is expected to increase monthly profit by $100, and each lathe machine by $150.
A press costs $8,000 and occupies 15 sq ft of floor space, while a lathe costs $4,000 and
occupies 30 sq ft. The workshop has a total purchase budget of $40,000 and at most 200 sq ft
of available floor space.
x1 = number of press machines (integer, ≥ 0) , x2 = number of lathe machines (integer, ≥ 0)
Objective Function:
Maximize Z=100x1 + 150x2
Constraints:
8000x1 + 4000x2 ≤ 40000 (Budget constraint)
15x1 + 30x2 ≤ 200 (Floor space constraint)
Variable restrictions:
x1, x2 ≥ 0, both integers x1, x2 ≥ 0, both integers
Mathematics for Computer Science Engineers
0-1 Integer Model Example
Problem Context:
•Research and Development (R&D) program with 4 projects: A, B, C, and D.
•Constraints on the number of Operations Research (OR) specialists and budget.
•Expected profit, cost, and specialist requirements vary per project.
•Special condition: Only project A or project B can be chosen, not both.
Key Elements:
Decision Variables:
•Binary variables xi ∈ {0,1} for each project i, where 1 means selecting the project, 0 means not selecting.
Constraints:
•Budget constraints based on project costs.
•Specialist availability constraints.
•Mutually exclusive project selection for projects A and B.
Mathematics for Computer Science Engineers
0-1 Integer Model Example
Problem Setup:
∙ Four research projects: A, B, C, and D
∙ Each project has expected profit, cost, and resource requirements
∙ Projects can either be selected (1) or not selected (0)
∙ Special constraint: Projects A and B are mutually exclusive (only one can be chosen)
Model Formulation:
Decision Variables:
∙ A, B, C, D ∈ {0, 1} where:
∙ A = 1 if project A is selected, 0 otherwise
∙ B = 1 if project B is selected, 0 otherwise
∙ C = 1 if project C is selected, 0 otherwise
∙ D =1 if project D is selected, 0 otherwise
Mathematics for Computer Science Engineers
0-1 Integer Model Example
Objective Function:
Maximize Z=300A + 90B + 400C + 150D
Constraints:
1. Budget constraint:
35,000A + 10,000B + 25,000C + 90,000D ≤ 120,000
1. OR Specialists constraint:
4A + 2B + 7C + 3D ≤ 12
Mutually exclusive projects:
A+B=1
This ensures either A or B is selected, but not both.
1. Binary restrictions:
A, B, C, D ∈ {0,1}
Key Insight:
The constraint A + B = 1 means exactly one of projects A or B must be chosen. This would result in solutions like A = 1, B = 0 or A
= 0, B = 1, but never both equal to 1.
Mathematics for Computer Science Engineers
Mixed Integer Model
Problem Description:
A real-estate investor has $500,000 to spend on townhouses and acres of land. Each townhouse
yields an annual return of $8,000 and costs $70,000 to buy; each acre of land yields $6,000 annually
and costs $30,000. Annual maintenance costs are $1,000 per townhouse and $2,000 per acre, and
the investor can spend at most $14,000 per year on maintenance. The investor must buy whole
townhouses and whole acres. How many townhouses and acres should be purchased to
maximize annual return, without exceeding the investment and maintenance budgets?
Decision Variables:
∙ x1 = number of townhouses (must be integer)
∙ x2 = acres of land (can be fractional)
Mathematics for Computer Science Engineers
Mixed Integer Model
Model Formulation:
Objective Function:
Maximize Z = 8000x1 + 6000x2
Constraints:
1. Investment budget:
70,000x1 + 30,000x2 ≤ 500,000
1. Maintenance budget:
1000x1 + 2000x2 ≤ 14,000
Variable Restrictions:
∙ x1 ≥ 0 and integer (townhouses must be whole units)
∙ x2 ≥ 0 (land can be fractional acres)
Key Features:
∙ Mixed nature: One variable must be integer, the other can be continuous (You can't build half a townhouse, but you can buy
fractional acres)
Mathematics for Computer Science Engineers
Integer Programming Solution Issues
The Rounding Problem:
Using the example from Machine Purchase Problem:
∙ Linear Programming solution: x1 = 2.22, x2 = 5.55
∙ Rounded solution: x1 = 2, x2 = 6
Problem: When substituting rounded values back into constraints:
∙ Original constraint: 15x1 + 30x2 ≤ 200
∙ Check: 15(2) + 30(6) = 30+180 = 210 > 200
∙ Result: Constraint is violated → Infeasible solution
Why Rounding Fails:
∙ Rounding may violate budget, space, or resource constraints
∙ The optimal integer solution may be far from the Linear Programming solution
∙ Need specialized integer programming algorithms like Branch-and-Bound
Mathematics for Computer Science Engineers
Branch-and-Bound Method for Integer Programming
Concept Overview:
∙ Branch-and-bound is a systematic algorithm to solve integer programming problems by dividing the problem
into smaller subproblems.
∙ Branch: Refers to constructing a tree structure where each node represents a subproblem with some variables
restricted.
∙ Bound: Uses an estimate of the objective function (a bound) to prune subproblems that cannot yield better
solutions than the current best.
∙ This approach avoids exhaustive search by ignoring infeasible or suboptimal branches early.
Mathematics for Computer Science Engineers
Branch-and-Bound Method for Integer Programming
When to Stop Branching or Prune?
1. When an integer feasible solution is found.
2. When a node is infeasible.
3. When further branching cannot improve objective z:
∙ For minimization, no potential for a lower z
∙ For maximization, no potential for a higher z
Note: Branch and Bound Method is applicable for any number of variables.
Branch-and-Bound Process Steps:
1. Start with the LP relaxation of the integer problem (ignore integrality).
2. If the LP solution is integer, it is optimal—stop.
3. Otherwise, select a variable with a fractional value and create two branches:
∙ One branch with the variable rounded down.
∙ Another with the variable rounded up.
4. Solve subproblems recursively, calculating bounds.
5. Prune branches where bounds show no improvement over the best-found solution.
6. Continue until all branches are either solved or pruned.
Mathematics for Computer Science Engineers
Branch-and-Bound Examples
Example:
Decision variables: x = [x1, x2]
• x1 ∈ {0,1,2,3,4,5,6,7,8}
• x2 ∈ {0,1,2,3,4,5}
Maximize, z=3x1+5x2
Constraints:
2x1+4x2<=25
x1 ≤ 8 and 2x2 ≤ 5
Given Z = 35.25
Determine:
Step 1: x, c, A, b
Relax the Integer Constraints
• Initially, ignore the integer restrictions on x1 and x2.
• Solve the relaxed linear optimization problem allowing x1, x2
to be any real (continuous) values.
Key Observations
∙ This example was solved quickly with just one level of branching.
∙ Because of the immediate integer feasible solution, no pruning occurred in this case.
∙ The value z=35.25 from the relaxed problem is an upper bound on the maximum integer solution achievable.
Mathematics for Computer Science Engineers
Branch and Bound Example
Example 2
Problem Setup
∙ Maximize: z = 5x1 + 4x2
∙ Subject to: x1 + x2 ≤ 5 and 10x1 + 6x2 ≤ 45
Decision variables x1, x2 can only take positive integer values.
Example 5: Maximize z = x1 + 4x2 such that 2x1 + 4x2 ≤ 7, 5x1 + 3x2 ≤ 15, where x, the design variables, can only take positive
integer values. Determine x, c, A, b. Solve x = [x1, x2]. The design variables are x1 and x2.
[Solution: (X1, X2) = (1,1), z = 5]
Example 6: Maximize z = 5x1 + 6x2 such that x1 + x2 ≤ 5 and, x1 + 7x2 ≤ 28 where x, the design variables, can only take positive
integer values. Determine x, c, A, b. Solve x = [x1, x2]. The design variables are x1 and x2.
[Solution: (X1, X2) = (2,3), z = 28]
Example 7: Maximize z = 5x1 + 8x2 such that 5x1 + 9x2 ≤ 45 and, x1 + x2 ≤ 6 where x, the design variables, can only take positive
integer values. Determine x, c, A, b. Solve x = [x1, x2]. The design variables are x1 and x2.
[Solution: (X1, X2) = (0,5), z = 40]
Mathematics for Computer Science Engineers
References
1. Engineering Optimization Theory and Practice, Fifth Edition, Singiresu S. Rao, 2020.
THANK YOU
Chandravva Hebbi
22
Mathematics for Computer Science Engineers
Unit - 4 Introduction to Nonlinear Optimization
Chandravva Hebbi
Computer Science and Engineering
Mathematics for Computer Science Engineers
Introduction to Nonlinear Optimization
Definition:
Non-linear optimization refers to maximizing or minimizing a non-linear objective function subject to a set of
constraints.
Unlike linear optimization (where objective and constraints are linear combinations of decision variables), non-linear
optimization deals with complex relationships such as polynomial, exponential, logarithmic, and other nonlinear
functions.
2) Decision Making:
Nonlinear optimization helps decision-makers evaluate trade-offs between conflicting objectives, such as cost vs.
quality or risk vs. return, aiding organizations in informed strategic decisions.
Mathematics for Computer Science Engineers
Usage of Nonlinear Optimization
In machine learning, especially for complex models such as neural networks, the loss functions are typically
nonlinear.
2) Feature Selection:
Identifying the most relevant features to improve model accuracy.
Algorithm Steps:
Initialize the starting point x0.
Update the point iteratively:
xn+1 = xn – α ∇f(xn)
Repeat until convergence.
Where:
α: learning rate
∇f(xn): gradient of function at xn.
Mathematics for Computer Science Engineers
Gradient Descent
Intuitive Example:
∙ Imagine a hiker descending a mountain blindfolded:
∙ The hiker knows if she is going down (making progress) or going up (losing progress).
∙ Repeating downhill steps leads to the base.
∙ Similarly, in machine learning, weights are adjusted based on the loss function until reaching the minimum.
Step 1: Form the Lagrangian Function: L(x, y, λ) = 4x2 + 3y2 + λ(10 – x − 2y)
Conclusion:
Optimal solution is x ≈ 1.58, y ≈ 4.23.
Mathematics for Computer Science Engineers
Lagrange Multipliers Examples
Example 2: Minimize cost for a container with volume V=1000,
Where C(x, h) = 5x2 + 12xh and constraint x2h=1000.
Step 1: Lagrangian Function
L(x,h,λ) = C(x,h) − λ(x2h − 1000)
Substitute cost and constraint:
L(x,h,λ) = 5x2 + 12xh − λ(x2h − 1000)
1 Min ≤ L = f + λg λ≥0
2 Min ≥ L = f − λg λ≤0
3 Max ≤ L = f − λg λ≥0
4 Max ≥ L = f + λg λ≤0
Rule of Thumb
● For Minimization → use +λg
4x₁ + 12x₂ = 0
12x₁ − 14x₂ = 0
Result:
The solution is trivial, yielding a point at the origin.
Maximum Value:
Zmax = 4900
Mathematics for Computer Science Engineers
Problems for students to solve
1. Engineering Optimization Theory and Practice, Fifth Edition, Singiresu S. Rao, 2020
THANK YOU
Chandravva Hebbi
30
Lagrange Multiplier Technique
● The Lagrange multiplier technique lets you find the maximum or minimum of a
multivariable function f(x, y, …) when there is some constraint on the input
values you are allowed to use.
● This technique only applies to constraints that look something like this:
g(x, y, …) =c
Here, g is another multivariable function with the same input space as f, and c is
some constant.
● The core idea is to look for points where the contour lines of f and g are tangent
to each other.
● This is the same as finding points where the gradient vectors of f and g are
parallel to each other.
● The entire process can be boiled down into setting the gradient of a certain
function, called the Lagrangian, equal to the zero vector.
Chandravva Hebbi
Computer Science and Engineering
Mathematics for Computer Science Engineers
Introduction to Nonlinear Optimization
Definition:
Non-linear optimization refers to maximizing or minimizing a non-linear objective function subject to a set of
constraints.
Unlike linear optimization (where objective and constraints are linear combinations of decision variables), non-
linear optimization deals with complex relationships such as polynomial, exponential, logarithmic, and other
nonlinear functions.
2) Decision Making:
Nonlinear optimization helps decision-makers evaluate trade-offs between conflicting objectives, such as cost vs.
quality or risk vs. return, aiding organizations in informed strategic decisions.
Mathematics for Computer Science Engineers
Usage of Nonlinear Optimization
In machine learning, especially for complex models such as neural networks, the loss functions are typically
nonlinear.
2) Feature Selection:
Identifying the most relevant features to improve model accuracy.
Algorithm Steps:
Initialize the starting point x0.
Update the point iteratively:
xn+1 = xn – α ∇f(xn)
Repeat until convergence.
Where:
α: learning rate
∇f(xn): gradient of function at xn.
Mathematics for Computer Science Engineers
Gradient Descent
Intuitive Example:
∙ Imagine a hiker descending a mountain blindfolded:
∙ The hiker knows if she is going down (making progress) or going up (losing progress).
∙ Repeating downhill steps leads to the base.
∙ Similarly, in machine learning, weights are adjusted based on the loss function until reaching the minimum.
1. Engineering Optimization Theory and Practice, Fifth Edition, Singiresu S. Rao, 2020
THANK YOU
Chandravva Hebbi
30
Mathematics for Computer Science Engineers
Chandravva Hebbi
Computer Science and Engineering
Mathematics for Computer Science Engineers
Introduction
However, many real-world problems do not satisfy these mathematical assumptions.
The search space may be discontinuous, noisy, nonlinear, or multi-modal (many peaks and valleys).
In such cases, traditional methods like Gradient Descent or Newton’s Method often get stuck in local minima or
even fail to converge.
The traditional methods require:
• The function to be continuous and differentiable.
• Starting points close to the global optimum.
• A well-behaved function (no many peaks or discontinuities).
To handle such complexity, we need optimization techniques that can:
● Work without gradient or derivative information.
● Explore a large, complex search space efficiently.
● Adapt to dynamic or uncertain environments.
.
Mathematics for Computer Science Engineers
Examples
The Problem: Real-world functions are messy or too complex as given below
Multi-modal Neural net hyperparameter tuning Many peaks → local minima traps
This need gave rise to a new class of methods collectively known as Computational
Intelligence (CI) or Soft Computing techniques
Mathematics for Computer Science Engineers
Computational Intelligence Techniques
Computational Intelligence refers to a set of adaptive problem-solving techniques that mimic human reasoning and
learning to handle complex, imprecise, and uncertain problems where traditional mathematical models fail.
Key Characteristics:
• Works with imprecision, approximation, and partial truth.
• Learns and adapts from data or experience.
• Often bio-inspired, but not necessarily based on nature.
Major Algorithms of CI:
Artificial Neural Networks (ANNs) – inspired by the brain’s learning.
Fuzzy Logic Systems – inspired by human reasoning with uncertainty.
Evolutionary Computation (like Genetic Algorithms) – inspired by biological evolution.
Swarm Intelligence (e.g., PSO, ACO) – inspired by social behavior of animals.
Goal: Create intelligent systems capable of learning, adaptation, and decision making
Mathematics for Computer Science Engineers
Nature-Inspired Computing
Nature-Inspired Computing draws inspiration directly from biological, physical, chemical, or ecological
processes found in nature to design algorithms and computational systems.
Key Idea:
It models how natural systems solve problems — like ant colonies finding shortest paths, birds flocking, or
fireflies communicating — and applies those mechanisms to computational optimization.
Note: All Nature-Inspired Computing techniques are part of Computational Intelligence, but not all
Computational Intelligence techniques are nature-inspired.
Mathematics for Computer Science Engineers
Bio-Inspired Algorithms
Bio-Inspired Computing (BIC) is a subfield of artificial intelligence and optimization that takes inspiration from biological systems
and processes found in nature — such as evolution, cell growth, swarm behavior, and immune systems — to design algorithms
and computational models that can solve complex problems.
Examples of Algorithms:
- Genetic Algorithm (Evolution)
- Particle Swarm Optimization (Swarm behavior)
- Ant Colony Optimization (Ant foraging)
- Artificial Immune System (Immune defense)
Bio-Inspired Algorithms mimic adaptation, cooperation, and learning in nature to explore the solution
space efficiently and escape local optima.
Mathematics for Computer Science Engineers
Genetic Algorithms (GAs) - Introduction
GA belongs to the family of evolutionary algorithms, inspired by natural selection.
It does not need derivatives, does not assume continuity, and works with complex or discrete search spaces.
Instead of following the slope like gradient descent, it evolves a population of possible solutions over time.
General Principles
∙ Genetic Algorithms are metaheuristic, search-based optimization techniques that use mechanisms analogous to biological
mutation, crossover, and selection.
∙ The process begins with a population of trial solutions and evolves these to optimize performance over time, referencing the
concept of "survival of the fittest" from Darwinian evolution.
Key Features
∙ GAs start with a population (set) of candidate solutions rather than optimizing a single solution at a time.
∙ For n decision variables, the recommended population size typically ranges from 2n to 4n. This diversity helps to avoid
convergence on local optima.
∙ GAs relies only on the objective function values, not on additional derivative information. This makes them suitable for
complex problems where derivatives are hard to compute or do not exist.
Mathematics for Computer Science Engineers
Basic Terminologies in Genetic Algorithms
Population
∙ A population: Set of all possible (encoded) solutions to a given problem, also called the pool of individuals, which enables the
application of genetic operators.
Chromosome / Individual
∙ A chromosome (individual): Represents one solution to the problem and is the carrier of genetic information. The fitness
(objective function value) characterizes the solution’s quality within the search space.
Gene
∙ Gene: One element position within a chromosome. Ex: Eye color
Allele
∙ Allele: The value a gene takes for a particular chromosome. Ex: Eye color=brown, blue
Fitness Function
∙ The fitness function evaluates the suitability of each solution, outputting a score that indicates "How good a solution is?".
∙ The fitness function is used synonymously with the objective function in evolutionary computations.
Population and Gene Mapping
Similar diagrams to above, but now highlight the specific role the fitness value (last column) plays for each chromosome.
Mathematics for Computer Science Engineers
Genetic Operators and Evolutionary Algorithm Features
Selection
∙ Selection methods include Roulette Wheel, Tournament, and Steady State selection. The aim is to enable good (fit)
chromosomes to participate in creating the next generation by duplicating the best and discarding the worst.
Crossover
∙ Types of crossovers include single-point, simulated binary, and linear crossover. Crossover creates new solutions by mixing
two (or more) parent chromosomes, promoting global search and the possibility of better solutions.
Mutation
∙ Mutation involves random or polynomial changes made to genes, ensuring diversity in the population and preventing
premature convergence.
∙ For example, bitwise mutations: 010110 → 010100.
Mathematics for Computer Science Engineers
Genotype, Phenotype, and Generations
Genotype
∙ Represents the population in computation space, i.e., encoded solutions easily processed by computers.
∙ Genotype: Bb (one brown-eye allele and one blue-eye allele)
Phenotype
∙ Represents how the encoded (genotype) solution maps to a real-world solution, contextualized for actual problems.
∙ Phenotype: Brown eyes (because brown is dominant over blue)
Generation
∙ Denotes a single iterative cycle in evolutionary algorithms, marking the progress of solutions through multiple iterations.
Example
P Generation (Parental generation):
•Parent 1: BB (brown eyes)
•Parent 2: bb (blue eyes)
These are the original parents we start with.
Types of Encoding:Binary Encoding → use bits (0s and 1s) and Real-Value Encoding → use actual numbers (floats)
Encoding Solution: Binary Representation
Each possible x is represented as a 5-bit binary string because 25 = 32 covers all integers from 0 to 31. For example:
● x = 5 is represented as binary 00101
● x = 25 is represented as binary 11001
Using binary strings as chromosomes allows the GA to apply standard genetic operators like crossover and mutation.
Step 1: Initialization (This random start gives a diverse gene pool to begin the search.)
· Randomly Generate a population of 4 binary strings randomly.
· Population: {00101, 11001, 00011, 10100}
· Corresponding values: x = {5,25,3,20}
· Fitness values: f(x) = {25,625,9,400}
Mathematics for Computer Science Engineers
Genetic Algorithm Optimization Example
Step 2: Selection using Roulette Wheel
· Each string (individual) is selected from a population with probability proportional to its fitness:
P(i)=Fitness of string I / Total Fitness
Where Fi is the fitness of the ith string. Roulette wheel selection is a widely used approach. The wheel is divided into
segments proportional to the fitness values. Multiple spins create a mating pool that statistically reflects fitness-based
selection probabilities.
● Higher fitness individuals have a greater chance to be selected for reproduction, preserving strong traits.
Mathematics for Computer Science Engineers
Genetic Algorithm Optimization Example
Step 3: Crossover (Recombination)
● Creating new strings (solutions) by exchanging information between selected parent strings in the mating pool.
● Different Crossover Approaches
a. ·One Point Crossover
b. ·Two-Point Crossover
● Mechanism
a. ·Two parent strings are randomly selected.
b. ·A crossover site is randomly chosen along the length of the strings.
c. ·The portions to the right of the crossover site are swapped between parents to generate two child strings.
● Example parents:
Standard crossover can produce invalid tours that repeat cities or miss cities.
·
Example
If single-point crossover is performed, the children may have duplicate cities or not include all required cities, leading to invalid
·
3. We are given N items where each item has some weight and profit associated with it. We are also given a bag with
capacity W, [i.e., the bag can hold at most W weight in it]. The target is to put the items into the bag such that the sum of
profits associated with them is the maximum possible.
4. Find the shortest route for a salesman to visit n cities exactly once and return to the starting point. A salesman needs to
visit 5 cities (A, B, C, D, E), and the distance between each pair of cities is given in the following table:
City A B C D E
A 0 10 15 20 25
B 10 0 35 25 30
C 15 35 0 30 20
D 20 25 30 0 15
E 25 30 20 15 0
Mathematics for Computer Science Engineers
References
1. Engineering Optimization Theory and Practice, Fifth Edition, Singiresu S. Rao, 2020.
THANK YOU
Chandravva Hebbi
24