doc/quicktour.dox
changeset 1514 c9b9bc63db4e
parent 1511 d6b95a59da26
child 1517 b303c1741c9a
     1.1 --- a/doc/quicktour.dox	Fri Jun 24 21:02:47 2005 +0000
     1.2 +++ b/doc/quicktour.dox	Fri Jun 24 21:03:08 2005 +0000
     1.3 @@ -18,14 +18,18 @@
     1.4  graph: a very good description can be found in the page
     1.5  about \ref graphs "graphs".
     1.6  
     1.7 -You will also want to assign data to the edges or nodes of the graph, for example a length or capacity function defined on the edges. You can do this in LEMON using so called \ref maps "maps". You can define a map on the nodes or on the edges of the graph and the value of the map (the range of the function) can be practically almost of any type. Read more about maps \ref maps-page "here".
     1.8 +You will also want to assign data to the edges or nodes of the graph, for
     1.9 +example a length or capacity function defined on the edges. You can do this in
    1.10 +LEMON using so called \b maps. You can define a map on the nodes or on the edges of the graph and the value of the map (the range of the function) can be practically almost of any type. Read more about maps \ref maps-page "here".
    1.11  
    1.12  Some examples are the following (you will find links next to the code fragments that help to download full demo programs: save them on your computer and compile them according to the description in the page about \ref getsart How to start using LEMON):
    1.13  
    1.14 -- First we give two examples that show how to instantiate a graph. The
    1.15 +<ul>
    1.16 +<li> First we give two examples that show how to instantiate a graph. The
    1.17  first one shows the methods that add nodes and edges, but one will
    1.18  usually use the second way which reads a graph from a stream (file).
    1.19 --# The following code fragment shows how to fill a graph with data. It creates a complete graph on 4 nodes. The type Listgraph is one of the LEMON graph types: the typedefs in the beginning are for convenience and we will suppose them later as well.
    1.20 +<ol>
    1.21 +<li>The following code fragment shows how to fill a graph with data. It creates a complete graph on 4 nodes. The type Listgraph is one of the LEMON graph types: the typedefs in the beginning are for convenience and we will suppose them later as well.
    1.22   \code
    1.23    typedef ListGraph Graph;
    1.24    typedef Graph::NodeIt NodeIt;
    1.25 @@ -42,9 +46,9 @@
    1.26  
    1.27  See the whole program in file \ref helloworld.cc.
    1.28  
    1.29 -If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs". 
    1.30 +    If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs". 
    1.31  
    1.32 --# The following code shows how to read a graph from a stream (e.g. a file). LEMON supports the DIMACS file format: it can read a graph instance from a file 
    1.33 +<li> The following code shows how to read a graph from a stream (e.g. a file). LEMON supports the DIMACS file format: it can read a graph instance from a file 
    1.34  in that format (find the documentation of the DIMACS file format on the web). 
    1.35  \code
    1.36  Graph g;
    1.37 @@ -53,8 +57,8 @@
    1.38  \endcode
    1.39  One can also store network (graph+capacity on the edges) instances and other things in DIMACS format and use these in LEMON: to see the details read the documentation of the \ref dimacs.h "Dimacs file format reader".
    1.40  
    1.41 -
    1.42 -- If you want to solve some transportation problems in a network then 
    1.43 +</ol>
    1.44 +<li> If you want to solve some transportation problems in a network then 
    1.45  you will want to find shortest paths between nodes of a graph. This is 
    1.46  usually solved using Dijkstra's algorithm. A utility
    1.47  that solves this is  the \ref lemon::Dijkstra "LEMON Dijkstra class".
    1.48 @@ -129,7 +133,7 @@
    1.49  by step and gain full control of the execution. For a detailed description, see the documentation of the \ref lemon::Dijkstra "LEMON Dijkstra class".
    1.50  
    1.51  
    1.52 -- If you want to design a network and want to minimize the total length
    1.53 +<li> If you want to design a network and want to minimize the total length
    1.54  of wires then you might be looking for a <b>minimum spanning tree</b> in
    1.55  an undirected graph. This can be found using the Kruskal algorithm: the 
    1.56  class \ref lemon::Kruskal "LEMON Kruskal class" does this job for you.
    1.57 @@ -137,11 +141,73 @@
    1.58  
    1.59  Ide Zsuzska fog irni!
    1.60  
    1.61 -- 
    1.62 +<li>Many problems in network optimization can be formalized by means of a
    1.63 +linear programming problem (LP problem, for short). In our library we decided
    1.64 +not to write an LP solver, since such packages are available in the commercial
    1.65 +world just as well as in the open source world, and it is also a difficult
    1.66 +task to compete these. Instead we decided to develop an interface that makes
    1.67 +it easier to use these solvers together with LEMON. So far we have an
    1.68 +interface for the commercial LP solver software \b CLPLEX (developed by ILOG)
    1.69 +and for the open source solver \b GLPK (a shorthand for Gnu Linear Programming
    1.70 +Toolkit). 
    1.71 +
    1.72 +We will show two examples, the first one shows how simple it is to formalize
    1.73 +and solve an LP problem in LEMON, while the second one shows how LEMON
    1.74 +facilitates solving network optimization problems using LP solvers.
    1.75 +
    1.76 +<ol>
    1.77 +<li>The following code shows how to solve an LP problem using the LEMON lp
    1.78 +interface. 
    1.79  
    1.80  \code
    1.81  
    1.82 +  //A default solver is taken
    1.83 +  LpDefault lp;
    1.84 +  typedef LpDefault::Row Row;
    1.85 +  typedef LpDefault::Col Col;
    1.86 +  
    1.87 +
    1.88 +  //This will be a maximization
    1.89 +  lp.max();
    1.90 +
    1.91 +  //We add coloumns (variables) to our problem
    1.92 +  Col x1 = lp.addCol();
    1.93 +  Col x2 = lp.addCol();
    1.94 +  Col x3 = lp.addCol();
    1.95 +
    1.96 +  //Constraints
    1.97 +  lp.addRow(x1+x2+x3 <=100);  
    1.98 +  lp.addRow(10*x1+4*x2+5*x3<=600);  
    1.99 +  lp.addRow(2*x1+2*x2+6*x3<=300);  
   1.100 +  //Nonnegativity of the variables
   1.101 +  lp.colLowerBound(x1, 0);
   1.102 +  lp.colLowerBound(x2, 0);
   1.103 +  lp.colLowerBound(x3, 0);
   1.104 +  //Objective function
   1.105 +  lp.setObj(10*x1+6*x2+4*x3);
   1.106 +  
   1.107 +  //Call the routine of the underlying LP solver
   1.108 +  lp.solve();
   1.109 +
   1.110 +  //Print results
   1.111 +  if (lp.primalStatus()==LpSolverBase::OPTIMAL){
   1.112 +    printf("Z = %g; x1 = %g; x2 = %g; x3 = %g\n", 
   1.113 +	   lp.primalValue(), 
   1.114 +	   lp.primal(x1), lp.primal(x2), lp.primal(x3));
   1.115 +  }
   1.116 +  else{
   1.117 +    std::cout<<"Optimal solution not found!"<<std::endl;
   1.118 +  }
   1.119 +
   1.120 +
   1.121  \endcode
   1.122  
   1.123 +See the whole code in \ref lp_demo.cc.
   1.124 +
   1.125 +<li>The second example shows how easy it is to formalize a network
   1.126 +optimization problem as an LP problem using the LEMON LP interface.
   1.127 +
   1.128 +</ol>
   1.129 +</ul>
   1.130  
   1.131  */