Improves a solution for the traveling salesman problem by using the 2-OPT method.
More...
|
| Opt2Tsp (Func< TNode, TNode, double > cost, IEnumerable< TNode > tour, double?tourCost) |
| Initializes the 2-OPT optimizer with the supplied tour. More...
|
|
void | Run () |
| Performs 2-OPT improvement steps until the tour cannot be improved this way. More...
|
|
bool | Step () |
| Performs an improvement step. More...
|
|
|
Func< TNode, TNode, double > | Cost [get, set] |
| A finite cost function on the node pairs. More...
|
|
IEnumerable< TNode > | Tour [get] |
|
double | TourCost [get, set] |
|
Improves a solution for the traveling salesman problem by using the 2-OPT method.
It starts from a precomputed tour (e.g. one returned by InsertionTsp<TNode>) and gradually improves it by repeatedly swapping two edges. It is advised to use this class for symmetric cost functions only.
- Template Parameters
-
Definition at line 276 of file Tsp.cs.
Satsuma.Opt2Tsp< TNode >.Opt2Tsp |
( |
Func< TNode, TNode, double > |
cost, |
|
|
IEnumerable< TNode > |
tour, |
|
|
double? |
tourCost |
|
) |
| |
Initializes the 2-OPT optimizer with the supplied tour.
- Parameters
-
cost | The cost function (should be symmetrical). |
tour | The tour to improve with 2-OPT. The starting node must be repeated at the end. |
tourCost | The known cost of tour . Use this parameter to speed up initialization. If null is supplied, then the tour cost is recalculated. |
Definition at line 291 of file Tsp.cs.
void Satsuma.Opt2Tsp< TNode >.Run |
( |
| ) |
|
Performs 2-OPT improvement steps until the tour cannot be improved this way.
Definition at line 321 of file Tsp.cs.
bool Satsuma.Opt2Tsp< TNode >.Step |
( |
| ) |
|
Performs an improvement step.
- Returns
true
if the objective could be improved.
Definition at line 300 of file Tsp.cs.
Func<TNode, TNode, double> Satsuma.Opt2Tsp< TNode >.Cost |
|
getset |
A finite cost function on the node pairs.
Definition at line 279 of file Tsp.cs.
IEnumerable<TNode> Satsuma.Opt2Tsp< TNode >.Tour |
|
get |
double Satsuma.Opt2Tsp< TNode >.TourCost |
|
getset |
The documentation for this class was generated from the following file: