You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »

The root page 15DOTs60ia13:Tutorial could not be found in space 15.S60 SSIM: Software Tools for Operations Research.

Local Search

Local search is a technique that takes as an input a feasible solution to a combinatorial optimization problem, and tries to produce a better solution. The idea, at a high level, is to search locally in a neighborhood of the input point for a solution that immediately improves the objective value. If no such solution can be found, our input is locally optimal and is returned. Otherwise, we recursively call our local search algorithm on the superior point found.

More formally, suppose we are given some optimization problem

Unknown macro: {mathdisplay}

\begin

Unknown macro: {aligned}

&\min & f(\mathbf x)
&\text

Unknown macro: {subject to}

& \mathbf x &\in S
\end

where

Unknown macro: {mathinline}

S \subset \mathbb R^n

and

Unknown macro: {mathinline}

f \colon S \to \mathbb R

. In local search, for every

Unknown macro: {mathinline}

\mathbf x \in S

, we must give some

Unknown macro: {mathinline}

N_

Unknown macro: {mathbf x}

to be the neighborhood of

Unknown macro: {mathinline}

\mathbf x

. Then given some initial feasible solution

Unknown macro: {mathinline}

\mathbf x_0

, for

Unknown macro: {mathinline}

n = 1,2,\ldots

, we let

Unknown macro: {mathdisplay}

\mathbf x_

Unknown macro: {n}

= \mathop

Unknown macro: {rm arg, min}

{\mathbf x \in N{\mathbf x_

Unknown macro: {n-1}

}} \left{ f(\mathbf x)\right}

To run a local search algorithm you begin with

Unknown macro: {mathinline}

\mathbf x_0

, and iterate the above process until it converges, i.e.

Unknown macro: {mathinline}

\mathbf x_

Unknown macro: {n+1}

= x_n

.

The key to making local search work is how we choose

Unknown macro: {mathinline}

N_

Unknown macro: {mathbf x}

. We need be able to efficiently optimize over

Unknown macro: {mathinline}

N_

Unknown macro: {mathbf x}

, otherwise our local search heuristic will be no easier to solve than our original problem. However, if we define

Unknown macro: {mathinline}

N_

Unknown macro: {mathbf x}

to be too small a set, then we may get stuck in a local optimum that isn't very good.

A few warnings about local search:

  • Without special problem structure, local search provides no guarentee on the quality of the solution produced relative to the global optimum
  • Generally speaking, we do not have a good upper bound on the number of iterations until local search converges. We have the trivial bounds of
    Unknown macro: {mathinline}

    S

    , which may be exponentially large, and (if the objective is guaranteed to be integer),
    Unknown macro: {mathinline}

    f(\mathbf x^*) - f(\mathbf x_0)

    , which can still often be exponential (assuming the problem has weights which are input in binary).

An example

TODO

Two-Opt for TSP

Two Opt is one of the simplest of many local search techniques for TSP. The idea is very simple: given a tour, choose any two (non-adjacent) edges, and swap the end points to make a new tour. For example, in the figure below, we begin with the tour given by the node ordering 1, 2, 3, 4, 5, 6, 7, 8, and we we pick the edge from 2 to 3 and the edge from 5 to 6 and swap, to produce the node ordering 1, 2, 5, 4, 3, 6, 7, 8.

Full Size

For a given tour, the neighborhood is the set of tours that can be made with such a swap (if

Unknown macro: {mathinline}

V

= n

, there are

Unknown macro: {mathinline}

\binom

Unknown macro: {n}
Unknown macro: {2}

). To optimize over all such neighborhoods, you simply enumerate them and calculate their cost relative to the existing tour (this can be done in

Unknown macro: {mathinline}

O(1)

as really you only need add and subtract the cost of the four edges you are adjusting). As discussed here, there are a variety of heuristics that can be used to speed up this process.

The origin of the name is as follows. For any tour, we can represent it as a vector

Unknown macro: {mathinline}

\mathbf x \in {0,1}^

Unknown macro: {|E|}

where for each

Unknown macro: {mathinline}

e \in E

, we have

Unknown macro: {mathinline}

x_e = 1

if

Unknown macro: {mathinline}

e

is in the tour and

Unknown macro: {mathinline}

x_e = 0

otherwise. If

Unknown macro: {mathinline}

T \subset E

is the set of edges in the current tour being considered by Two-Opt, and

Unknown macro: {mathinline}

\mathcal T \subset {0,1}^

Unknown macro: {|E|}

is the set of all feasible tours, then the set of tours considered by Two-Opt this round is exactly

Unknown macro: {mathdisplay}

\begin

Unknown macro: {aligned}

\sum_

Unknown macro: {e in E setminus T}

x_e &\leq 2,
\mathbf x &\in \mathcal T.
\end

More generally, one can consider swapping the end points of up to

Unknown macro: {mathinline}

k

edges, giving the local search algorithm

Unknown macro: {mathinline}

k

-Opt. However, with a naïve implementation, this will require

Unknown macro: {mathinline}

O(n^k)

time per call on

Unknown macro: {mathinline}

n

vertices (times the recursive depth!), the cost prohibitive.

Implementing Two-Opt for User Generated Solutions

We have provided you with a simple Two-Opt implementation, TwoOptSolver. As a minor optimization, it caches ever tour it has ever checked the neighborhood of, so it can abort the search as soon as it has been determined that it will end up in a local optimum that has already been visited. It has a simple interface

Method Name

Return Type

Arguments

Description

searchNeighborhoodEdgeList

Set<E>

List<E> startTour

Applies Two-Opt recurssively to startTour, returns a locally optimal tour, or null if an already visited tour is hit.

searchNeighborhoodEdgeSet

Set<E>

Set<E> startTour

Same as above, but must pay a one time

Unknown macro: {mathinline}

O(|V|^2)

to convert into the List<E> format.

  • No labels