Optimization_Part9
Optimization_Part9
1
Some Illustrative Applications
• Design of an offshore pipeline network to transport natural gas from the source to
distribution points with the objective of minimizing the cost of constructing the pipeline.
• Determination of the shortest route between two cities in an existing network of roads in
order to minimize transportation costs.
• Determination of the maximum capacity (in tons per year) of a pipeline network.
• Determination of the time schedule (start and completion dates) for the activities of a
construction project.
2
Some Illustrative Applications
A pharmaceutical company needs to deliver temperature-sensitive vaccines from their
central cold storage to multiple hospitals:
• Network nodes: Storage facilities, transfer points, hospitals
• Edge weights: Distance, time, or composite cost (fuel + time + refrigeration)
• Constraints: Maximum time due to cold chain requirements
• Objective: Minimize total delivery time/cost while maintaining temperature control
3
Some Illustrative Applications
A beverage distributor making daily deliveries to retail stores:
• Network nodes: Distribution centre and retail stores
• Edge weights: Travel time between locations including traffic patterns
• Constraints: Vehicle capacity, delivery time windows
• Objective: Minimize total route distance while serving all stores
• Additional considerations: Loading/unloading times, store opening hours
4
Some Illustrative Applications
An automotive parts manufacturer shipping through multiple transportation modes:
• Source: Manufacturing plants
• Sink: Assembly plants
• Nodes: Intermediate warehouses and cross-dock facilities
• Edge capacities: Transportation mode limitations
• Truck routes: Maximum daily truckloads
• Rail connections: Weekly railcar capacity
• Ocean freight: Container ship scheduling
• Constraints: Storage capacity at warehouses
• Objective: Maximize parts flow to assembly plants while respecting all capacity constraints
5
only. A directed network has all directed arcs.
A path is a set of arcs joining two distinct nodes, p
the network. For example, in Figure 6.1, arcs (1, 2), (2, 3
between nodes 1 and 5. A path forms a cycle or a loop
itself through other nodes. In Figure 6.1, arcs (2, 3), (3, 4
A network is said to be connected if every two d
What is a network? least one path. The network in Figure 6.1 demonstrates
a cycle-free connected network comprised of a subset o
𝑉 = 1, 2, 3, 4, 5
• A network consists of a tree
set of links all the nodes of the network. Figure 6.2 prov
nodes (or vertices) linked by arcs 𝐸 = { 1, 2 , 1, 3 , 2, 3 , 2, 5 , 3, 4 , 3, 5 , 4, 2 , (4, 5)}
(or edges).
spanning tree from the network in Figure 6.1.
• The notation for describing a
network is (𝑁, 𝐴), where 𝑁 is the 1 3 5
set of nodes, and 𝐴 is the set of
arcs (or alternatively, (𝑉, 𝐸) where
𝑉 is the set of vertices and 𝐸 is the Figure 6
set of edges). 2 4
Example
Figure 6.2
6
Examples of a tree and a spanning tree
1 3 1 3
Networks
• Flow
• Associated with each network is a flow (e.g., oil products flow in a pipeline and automobile traffic
flow in highways).
• The maximum flow in a network can be finite or infinite, depending on the capacity of its arcs.
• Direction
• An arc is said to be directed or oriented if it allows positive flow in one direction only. A directed
network has all directed arcs.
• Path
• A path is a set of arcs joining two distinct nodes, passing through other nodes in the network.
• A path forms a cycle or a loop if it connects a node back to itself through other nodes
7
itselfInthrough
through other nodes. other
Figure 6.1, nodes.
arcs (2, 3),In(3,
Figure 6.1,
4), and (4,arcs (2, 3),a (3,
2) form 4), and (4, 2) form a cycle.
cycle.
A network is said to be A connected
network isifsaidevery be connected
to two if every
distinct nodes are two
linkeddistinct
by at nodes are linked b
least one
one path. The network path. The
in Figure network in Figure
6.1 demonstrates 6.1 demonstrates
this type of network. Athis is of network. A tr
treetype
le-free connected network
a cycle-free comprised
connected of anetwork
subset of all the nodes,
comprised and a spanning
of a subset of all the nodes, and a span
inks all the nodestree
of the
linksnetwork. Figure of
all the nodes 6.2the
provides
network.examples of aprovides
Figure 6.2 tree andexamples
a of a tree a
ning tree from the spanning
network in Figure
tree from6.1.
the network in Figure 6.1.
1 3 1 5 3 5
Networks
Figure 6.1 Figure 6.1
2 4 2
• A network is said to be connected if every two distinct 4
nodes are linked by at least one path. (The
Example of (N, A) Network Example of (N, A) Network
network shown on the earlier slide is a connected network.)
e 6.2 • A tree Figure 6.2 connected network comprised of a subset of all the nodes, and a spanning
is a cycle-free
ples of a tree andtree
a spanning
links
Examplestreenodes
all the of the
of a tree network.
and a spanning tree
1 3 11 33 1 5 3 5
9
The Shortest Route Problem
Minimize Total Distance 𝑍 = > 𝑐!# ⋅ 𝑥!# Minimize the total path cost.
!,# ∈ &
10
Maximal Flow Model
• Nodes (or edges) have capacities – how much resource (such as water, data, or traffic) can
flow through that edge/node.
• Find the greatest possible flow of a resource through a network from a designated source
node to a sink node, without violating capacity constraints on the edges of the network.
• Applications
• Transportation Networks – maximizing traffic flow through roads while avoiding congestion.
• Data Networks – maximizing data transfer between servers.
• Supply Chains – optimizing the flow of goods from suppliers to consumers.
• Electrical Networks – maximizing the current flow in power grids.
11
The objective is to maximize
LP Formulation of the Maximize > 𝑥(# or
the total flow into the sink (𝑡)
Maximize > 𝑥!) or equivalently the total flow
Maximal Flow Problem # ! out of the source (𝑠)
12
Illustration
Source (s): 1
Sink/Target (t): 5
13
# AMPL Code for Maximal Flow Problem
# Sets
set NODES; # Set of nodes
set ARCS within (NODES cross NODES); # Set of arcs (i, j)
# Parameters
param capacity {ARCS} >= 0; # Capacity of each arc
param source symbolic; # Source node
param sink symbolic; # Sink node
# Variables
var flow {ARCS} >= 0; # Flow on each arc
param capacity :=
[1, 2] 15
[1, 3] 10
[2, 3] 5
[2, 4] 10
[2, 5] 5
[3, 4] 10
[3, 5] 10
[4, 5] 15;
Source (s): 1
10 5
10
Sink/Target (t): 5
Maximal flow = ? 10
15
16
Solution
Gurobi 11.0.2: optimal solution; objective 25
3 simplex iterations
flow :=
1 2 15
1 3 10
2 3 5
2 4 10
2 5 0
3 4 5
3 5 10
4 5 15
;
TotalFlow = 25
17
The Traveling Salesman Problem
• Find the shortest possible route for a salesman who needs to visit a specified set of cities
exactly once and return to the starting point.
• The goal is to minimize the total travel distance or cost while adhering to the constraint
of visiting each city only once.
• TSP is computationally complex, classified as an NP-hard problem, meaning that there is
no known polynomial-time algorithm to solve all instances of TSP optimally.
18
Difference between the TSP and the Shortest Route Problem
Aspect Traveling Salesman Problem (TSP) Shortest Path Problem
Goal Find a complete tour visiting all nodes once. Find the shortest route between two nodes.
Scope Global (entire graph is involved). Local (focuses on a subset of the graph).
19
Formulation
• Set of Nodes: 𝑁 (the cities).
• Distances (𝑑!" ): is the distance (cost) between node 𝑖 and node 𝑗, where 𝑖, 𝑗 ∈ 𝑁.
• Decision Variable (𝑥!" ): A binary variable that equals 1 if the salesman travels from
node 𝑖 to node 𝑗, and 0 otherwise.
• 𝑢! : A continuous variable used for subtour elimination.
20
Formulation
Minimize > > 𝑑!# ⋅ 𝑥!# Minimize the total distance travelled.
!∈+ #∈+
> 𝑥!# = 1, ∀𝑖 ∈𝑁 The salesman leaves each city (node) exactly once.
#∈+,#,!
> 𝑥!# = 1, ∀𝑗 ∈𝑁 The salesman enters each city (node) exactly once.
!∈+, !,#
Subtour elimination: The variable 𝑢! is used to represent the
position of node 𝑖 in the tour. If the edge 𝑥!" = 1, then node 𝑗
𝑢! − 𝑢# + 𝑁 ⋅ 𝑥!# ≤ 𝑁 − 1, ∀ 𝑖, 𝑗 ∈ 𝑁, 𝑖 ≠ 𝑗
must come after node 𝑖, and the difference (𝑢! − 𝑢" ) must be less
than or equal to ∣ 𝑁 ∣ −1. This ensures that no cycles smaller than
the full tour can be formed. |𝑁| is the number of nodes.
21
Solve the TSP for this network
22
# Sets
set NODES; # Set of nodes (1, 2, 3, 4, 5) AMPL Model for the TSP
set ARCS within {NODES, NODES}; # Set of directed edges (i, j)
# Parameters
param dist {ARCS} >= 0; # Distance between nodes (i, j)
param num_nodes := card(NODES); # number of nodes is the cardinality of the set NODES
# Variables
var x {ARCS} binary; # Binary decision variable: 1 if arc (i,j) is selected, 0 otherwise
var u {NODES} >= 0; # Subtour elimination variables
23
AMPL Data for the TSP
data;
24
TSP Variants
• Vehicle Routing Problem (VRP) – multiple • CVRP with time windows and
vehicles are available pickup/delivery (CVRPTWPD)
25