| 1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
| 2 | 2 |
* |
| 3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
| 4 | 4 |
* |
| 5 | 5 |
* Copyright (C) 2003-2009 |
| 6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
| 7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
| 8 | 8 |
* |
| 9 | 9 |
* Permission to use, modify and distribute this software is granted |
| 10 | 10 |
* provided that this copyright notice appears in all copies. For |
| 11 | 11 |
* precise terms see the accompanying LICENSE file. |
| 12 | 12 |
* |
| 13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
| 14 | 14 |
* express or implied, and with no claim as to its suitability for any |
| 15 | 15 |
* purpose. |
| 16 | 16 |
* |
| 17 | 17 |
*/ |
| 18 | 18 |
|
| 19 | 19 |
/// \ingroup tools |
| 20 | 20 |
/// \file |
| 21 |
/// \brief Special plane |
|
| 21 |
/// \brief Special plane graph generator. |
|
| 22 | 22 |
/// |
| 23 | 23 |
/// Graph generator application for various types of plane graphs. |
| 24 | 24 |
/// |
| 25 | 25 |
/// See |
| 26 | 26 |
/// \code |
| 27 | 27 |
/// lgf-gen --help |
| 28 | 28 |
/// \endcode |
| 29 |
/// for more |
|
| 29 |
/// for more information on the usage. |
|
| 30 | 30 |
|
| 31 | 31 |
#include <algorithm> |
| 32 | 32 |
#include <set> |
| 33 | 33 |
#include <ctime> |
| 34 | 34 |
#include <lemon/list_graph.h> |
| 35 | 35 |
#include <lemon/random.h> |
| 36 | 36 |
#include <lemon/dim2.h> |
| 37 | 37 |
#include <lemon/bfs.h> |
| 38 | 38 |
#include <lemon/counter.h> |
| 39 | 39 |
#include <lemon/suurballe.h> |
| 40 | 40 |
#include <lemon/graph_to_eps.h> |
| 41 | 41 |
#include <lemon/lgf_writer.h> |
| 42 | 42 |
#include <lemon/arg_parser.h> |
| 43 | 43 |
#include <lemon/euler.h> |
| 44 | 44 |
#include <lemon/math.h> |
| 45 | 45 |
#include <lemon/kruskal.h> |
| 46 | 46 |
#include <lemon/time_measure.h> |
| 47 | 47 |
|
| 48 | 48 |
using namespace lemon; |
| 49 | 49 |
|
| 50 | 50 |
typedef dim2::Point<double> Point; |
| 51 | 51 |
|
| 52 | 52 |
GRAPH_TYPEDEFS(ListGraph); |
| 53 | 53 |
|
| ... | ... |
@@ -665,70 +665,71 @@ |
| 665 | 665 |
std::cout << "2-opt the tour..." << std::endl; |
| 666 | 666 |
|
| 667 | 667 |
tsp_improve(); |
| 668 | 668 |
|
| 669 | 669 |
std::cout << "Total arc length (2-opt tour) : " << totalLen() << std::endl; |
| 670 | 670 |
} |
| 671 | 671 |
|
| 672 | 672 |
|
| 673 | 673 |
int main(int argc,const char **argv) |
| 674 | 674 |
{
|
| 675 | 675 |
ArgParser ap(argc,argv); |
| 676 | 676 |
|
| 677 | 677 |
// bool eps; |
| 678 | 678 |
bool disc_d, square_d, gauss_d; |
| 679 | 679 |
// bool tsp_a,two_a,tree_a; |
| 680 | 680 |
int num_of_cities=1; |
| 681 | 681 |
double area=1; |
| 682 | 682 |
N=100; |
| 683 | 683 |
// girth=10; |
| 684 | 684 |
std::string ndist("disc");
|
| 685 | 685 |
ap.refOption("n", "Number of nodes (default is 100)", N)
|
| 686 | 686 |
.intOption("g", "Girth parameter (default is 10)", 10)
|
| 687 | 687 |
.refOption("cities", "Number of cities (default is 1)", num_of_cities)
|
| 688 | 688 |
.refOption("area", "Full relative area of the cities (default is 1)", area)
|
| 689 |
.refOption("disc", "Nodes are evenly distributed on a unit disc (default)",
|
|
| 689 |
.refOption("disc", "Nodes are evenly distributed on a unit disc (default)",
|
|
| 690 |
disc_d) |
|
| 690 | 691 |
.optionGroup("dist", "disc")
|
| 691 |
.refOption("square", "Nodes are evenly distributed on a unit square",
|
|
| 692 |
.refOption("square", "Nodes are evenly distributed on a unit square",
|
|
| 693 |
square_d) |
|
| 692 | 694 |
.optionGroup("dist", "square")
|
| 693 |
.refOption("gauss",
|
|
| 694 |
"Nodes are located according to a two-dim gauss distribution", |
|
| 695 |
|
|
| 695 |
.refOption("gauss", "Nodes are located according to a two-dim Gauss "
|
|
| 696 |
"distribution", gauss_d) |
|
| 696 | 697 |
.optionGroup("dist", "gauss")
|
| 697 |
// .mandatoryGroup("dist")
|
|
| 698 | 698 |
.onlyOneGroup("dist")
|
| 699 |
.boolOption("eps", "Also generate .eps output (prefix.eps)")
|
|
| 700 |
.boolOption("nonodes", "Draw the edges only in the generated .eps")
|
|
| 701 |
.boolOption("dir", "Directed digraph is generated (each arcs are replaced by two directed ones)")
|
|
| 702 |
.boolOption("2con", "Create a two connected planar digraph")
|
|
| 699 |
.boolOption("eps", "Also generate .eps output (<prefix>.eps)")
|
|
| 700 |
.boolOption("nonodes", "Draw only the edges in the generated .eps output")
|
|
| 701 |
.boolOption("dir", "Directed graph is generated (each edge is replaced by "
|
|
| 702 |
"two directed arcs)") |
|
| 703 |
.boolOption("2con", "Create a two connected planar graph")
|
|
| 703 | 704 |
.optionGroup("alg","2con")
|
| 704 | 705 |
.boolOption("tree", "Create a min. cost spanning tree")
|
| 705 | 706 |
.optionGroup("alg","tree")
|
| 706 | 707 |
.boolOption("tsp", "Create a TSP tour")
|
| 707 | 708 |
.optionGroup("alg","tsp")
|
| 708 | 709 |
.boolOption("tsp2", "Create a TSP tour (tree based)")
|
| 709 | 710 |
.optionGroup("alg","tsp2")
|
| 710 |
.boolOption("dela", "Delaunay triangulation
|
|
| 711 |
.boolOption("dela", "Delaunay triangulation graph")
|
|
| 711 | 712 |
.optionGroup("alg","dela")
|
| 712 | 713 |
.onlyOneGroup("alg")
|
| 713 | 714 |
.boolOption("rand", "Use time seed for random number generator")
|
| 714 | 715 |
.optionGroup("rand", "rand")
|
| 715 | 716 |
.intOption("seed", "Random seed", -1)
|
| 716 | 717 |
.optionGroup("rand", "seed")
|
| 717 | 718 |
.onlyOneGroup("rand")
|
| 718 | 719 |
.other("[prefix]","Prefix of the output files. Default is 'lgf-gen-out'")
|
| 719 | 720 |
.run(); |
| 720 | 721 |
|
| 721 | 722 |
if (ap["rand"]) {
|
| 722 | 723 |
int seed = int(time(0)); |
| 723 | 724 |
std::cout << "Random number seed: " << seed << std::endl; |
| 724 | 725 |
rnd = Random(seed); |
| 725 | 726 |
} |
| 726 | 727 |
if (ap.given("seed")) {
|
| 727 | 728 |
int seed = ap["seed"]; |
| 728 | 729 |
std::cout << "Random number seed: " << seed << std::endl; |
| 729 | 730 |
rnd = Random(seed); |
| 730 | 731 |
} |
| 731 | 732 |
|
| 732 | 733 |
std::string prefix; |
| 733 | 734 |
switch(ap.files().size()) |
| 734 | 735 |
{
|
0 comments (0 inline)