Documentation (lp_demo,lp_maxflow) and slight changes (rest).
authorathos
Wed, 20 Jul 2005 16:05:04 +0000
changeset 157715098fb5275c
parent 1576 e5957f8866e6
child 1578 1d3a1bcbc874
Documentation (lp_demo,lp_maxflow) and slight changes (rest).
demo/coloring.cc
demo/dim_to_dot.cc
demo/lp_demo.cc
demo/lp_maxflow_demo.cc
demo/sub_gad_input.lgf
demo/sub_graph_adaptor_demo.cc
     1.1 --- a/demo/coloring.cc	Wed Jul 20 16:03:41 2005 +0000
     1.2 +++ b/demo/coloring.cc	Wed Jul 20 16:05:04 2005 +0000
     1.3 @@ -16,7 +16,7 @@
     1.4  {
     1.5    if(argc<2)
     1.6    {
     1.7 -      std::cerr << "USAGE: coloring <input_file.lgf>" << std::endl;
     1.8 +      std::cerr << "USAGE: coloring input_file.lgf" << std::endl;
     1.9        std::cerr << "The file 'input_file.lgf' has to contain a graph in LEMON format together with a nodemap called 'coords' to draw the graph (e.g. sample.lgf is not such a file)." << std::endl;
    1.10        return 0;
    1.11    }
     2.1 --- a/demo/dim_to_dot.cc	Wed Jul 20 16:03:41 2005 +0000
     2.2 +++ b/demo/dim_to_dot.cc	Wed Jul 20 16:05:04 2005 +0000
     2.3 @@ -6,6 +6,16 @@
     2.4  // This program can be an aid in making up to date visualized documantation 
     2.5  // of demo programs.
     2.6  
     2.7 +// For later documentation (if marci does not do it)
     2.8 +// Az a graphviz csomag egy egyszeru formatuma, ami egy graphrajzolo csomag.
     2.9 +// Az EdgeSubGraphAdaptor doksijaban szerepel egy kirajzolt graf. Azt nem
    2.10 +// kezzel csinaltam, hanem a megfelelo dim file-bol ezzel a progival. A
    2.11 +// doxygen ugyanis ilyet eszik, igy a juzer vizualisan is latja a grafot a
    2.12 +// doksiban, es sajat maga is le tudja futtatni az algoritmust, mert ott van
    2.13 +// a kezeben a dim file is. Es mivel ez egy generalt file, ezert ha vmit
    2.14 +// valtoztatunk a dim-en, ezt is konnyu bemasolni. Uff.
    2.15 +
    2.16 +
    2.17  #include <iostream>
    2.18  #include <fstream>
    2.19  
    2.20 @@ -17,8 +27,19 @@
    2.21  using std::cout;
    2.22  using std::endl;
    2.23  
    2.24 -int main()
    2.25 -{    
    2.26 +int main(int argc, char *argv[]) 
    2.27 +{
    2.28 +  if(argc<2)
    2.29 +  {
    2.30 +      std::cerr << "USAGE: sub_graph_adaptor_demo input_file.dim" << std::endl;
    2.31 +      std::cerr << "The file 'input_file.dim' has to contain a max flow instance in DIMACS format (e.g. sub_graph_adaptor_demo.dim is such a file)." << std::endl;
    2.32 +      return 0;
    2.33 +  }
    2.34 +
    2.35 +
    2.36 +  //input stream to read the graph from
    2.37 +  std::ifstream is(argv[1]);
    2.38 +
    2.39    typedef SmartGraph Graph;
    2.40  
    2.41    typedef Graph::Edge Edge;
    2.42 @@ -31,7 +52,7 @@
    2.43    Node s, t;
    2.44    LengthMap length(g);
    2.45  
    2.46 -  readDimacs(std::cin, g, length, s, t);
    2.47 +  readDimacs(is, g, length, s, t);
    2.48  
    2.49    cout << "digraph lemon_dot_example {" << endl;
    2.50    cout << "  node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
     3.1 --- a/demo/lp_demo.cc	Wed Jul 20 16:03:41 2005 +0000
     3.2 +++ b/demo/lp_demo.cc	Wed Jul 20 16:05:04 2005 +0000
     3.3 @@ -1,3 +1,29 @@
     3.4 +/* -*- C++ -*-
     3.5 + * demo/graph_to_eps.cc - Part of LEMON, a generic C++ optimization library
     3.6 + *
     3.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     3.8 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
     3.9 + *
    3.10 + * Permission to use, modify and distribute this software is granted
    3.11 + * provided that this copyright notice appears in all copies. For
    3.12 + * precise terms see the accompanying LICENSE file.
    3.13 + *
    3.14 + * This software is provided "AS IS" with no warranty of any kind,
    3.15 + * express or implied, and with no claim as to its suitability for any
    3.16 + * purpose.
    3.17 + *
    3.18 + */
    3.19 +
    3.20 +/// \ingroup demos
    3.21 +/// \file
    3.22 +/// \brief A program demonstrating the LEMON LP solver interface
    3.23 +///
    3.24 +/// This program is a simple application of the LEMON LP solver
    3.25 +/// interface: we formulate a linear programming (LP) problem and then
    3.26 +/// solve it using the underlying solver (GLPK or CPLEX for
    3.27 +/// example). For the detailed documentation of the LEMON LP solver
    3.28 +/// interface read \ref lemon::LpSolverBase "this".
    3.29 +
    3.30  #ifdef HAVE_CONFIG_H
    3.31  #include <config.h>
    3.32  #endif
    3.33 @@ -13,10 +39,14 @@
    3.34  
    3.35  using namespace lemon;
    3.36  
    3.37 +
    3.38 +
    3.39  #ifdef HAVE_GLPK
    3.40  typedef LpGlpk LpDefault;
    3.41 +const char default_solver_name[]="GLPK";
    3.42  #elif HAVE_CPLEX
    3.43  typedef LpCplex LpDefault;
    3.44 +const char default_solver_name[]="CPLEX";
    3.45  #endif
    3.46  
    3.47  int main()
    3.48 @@ -30,6 +60,9 @@
    3.49    typedef LpDefault::Col Col;
    3.50    
    3.51  
    3.52 +  std::cout<<"A program demonstrating the LEMON LP solver interface"<<std::endl; 
    3.53 +  std::cout<<"Solver used: "<<default_solver_name<<std::endl;
    3.54 +
    3.55    //This will be a maximization
    3.56    lp.max();
    3.57  
    3.58 @@ -54,7 +87,8 @@
    3.59  
    3.60    //Print results
    3.61    if (lp.primalStatus()==LpSolverBase::OPTIMAL){
    3.62 -    printf("Z = %g; x1 = %g; x2 = %g; x3 = %g\n", 
    3.63 +    std::cout<<"Optimal solution found!"<<std::endl;
    3.64 +    printf("optimum value = %g; x1 = %g; x2 = %g; x3 = %g\n", 
    3.65  	   lp.primalValue(), 
    3.66  	   lp.primal(x1), lp.primal(x2), lp.primal(x3));
    3.67    }
     4.1 --- a/demo/lp_maxflow_demo.cc	Wed Jul 20 16:03:41 2005 +0000
     4.2 +++ b/demo/lp_maxflow_demo.cc	Wed Jul 20 16:05:04 2005 +0000
     4.3 @@ -44,8 +44,10 @@
     4.4  
     4.5  #ifdef HAVE_GLPK
     4.6  typedef LpGlpk LpDefault;
     4.7 +const char default_solver_name[]="GLPK";
     4.8  #elif HAVE_CPLEX
     4.9  typedef LpCplex LpDefault;
    4.10 +const char default_solver_name[]="CPLEX";
    4.11  #endif
    4.12  
    4.13  
    4.14 @@ -96,6 +98,8 @@
    4.15    lp.messageLevel(3);
    4.16  #endif
    4.17  
    4.18 +  std::cout<<"Solver used: "<<default_solver_name<<std::endl;
    4.19 +
    4.20    //Solve with the underlying solver
    4.21    lp.solve();
    4.22  
    4.23 @@ -106,7 +110,7 @@
    4.24  {
    4.25    if(argc<2)
    4.26    {
    4.27 -      std::cerr << "  USAGE: lp_maxflow_demo <input_file.lgf>" << std::endl;
    4.28 +      std::cerr << "  USAGE: lp_maxflow_demo input_file.lgf" << std::endl;
    4.29        std::cerr << "  The file 'input_file.lgf' has to contain a max "
    4.30  		<< "flow instance in\n"
    4.31  		<< "  LEMON format (e.g. sample.lgf is such a file)."
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/demo/sub_gad_input.lgf	Wed Jul 20 16:05:04 2005 +0000
     5.3 @@ -0,0 +1,27 @@
     5.4 +@nodeset 
     5.5 +id
     5.6 +6
     5.7 +5
     5.8 +4
     5.9 +3
    5.10 +2
    5.11 +1
    5.12 +0
    5.13 +@edgeset 
    5.14 +                id      length
    5.15 +5       6       9       4
    5.16 +4       6       8       2
    5.17 +3       5       7       1
    5.18 +2       5       6       3
    5.19 +2       6       5       5
    5.20 +2       4       4       2
    5.21 +1       4       3       3
    5.22 +0       3       2       1
    5.23 +0       2       1       2
    5.24 +0       1       0       3
    5.25 +@nodes 
    5.26 +source 0
    5.27 +target 6
    5.28 +@edges 
    5.29 +@attributes 
    5.30 +@end
     6.1 --- a/demo/sub_graph_adaptor_demo.cc	Wed Jul 20 16:03:41 2005 +0000
     6.2 +++ b/demo/sub_graph_adaptor_demo.cc	Wed Jul 20 16:05:04 2005 +0000
     6.3 @@ -16,6 +16,11 @@
     6.4  #include <lemon/preflow.h>
     6.5  #include <tight_edge_filter_map.h>
     6.6  
     6.7 +
     6.8 +
     6.9 +//#include <lemon/graph_reader.h>
    6.10 +//#include <lemon/graph_writer.h>
    6.11 +
    6.12  using namespace lemon;
    6.13  
    6.14  using std::cout;
    6.15 @@ -25,7 +30,7 @@
    6.16  {
    6.17    if(argc<2)
    6.18    {
    6.19 -      std::cerr << "USAGE: sub_graph_adaptor_demo <input_file.dim>" << std::endl;
    6.20 +      std::cerr << "USAGE: sub_graph_adaptor_demo input_file.dim" << std::endl;
    6.21        std::cerr << "The file 'input_file.dim' has to contain a max flow instance in DIMACS format (e.g. sub_graph_adaptor_demo.dim is such a file)." << std::endl;
    6.22        return 0;
    6.23    }
    6.24 @@ -48,6 +53,16 @@
    6.25  
    6.26    readDimacs(is, g, length, s, t);
    6.27  
    6.28 +//     GraphWriter<SmartGraph> writer(std::cout, g);
    6.29 +//     writer.writeEdgeMap("length", length);
    6.30 +//     writer.writeNode("source",s);
    6.31 +//     writer.writeNode("target",t);
    6.32 +//     writer.run();
    6.33 +
    6.34 +//   GraphReader<ListGraph> reader(is,g);
    6.35 +//   reader.readNode("source",s).readNode("target",t)
    6.36 +//     .readEdgeMap("length",length).run();
    6.37 +
    6.38    cout << "edges with lengths (of form id, source--length->target): " << endl;
    6.39    for(EdgeIt e(g); e!=INVALID; ++e) 
    6.40      cout << " " << g.id(e) << ", " << g.id(g.source(e)) << "--"