doc/getstart.dox
author deba
Tue, 06 Mar 2007 17:03:37 +0000
changeset 2394 8b9b44a9c754
parent 2167 7e109b222053
child 2395 fe5966d8acfc
permissions -rw-r--r--
Bug fix missing include
alpar@2391
     1
/* -*- C++ -*-
alpar@2391
     2
 *
alpar@2391
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@2391
     4
 *
alpar@2391
     5
 * Copyright (C) 2003-2007
alpar@2391
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@2391
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@2391
     8
 *
alpar@2391
     9
 * Permission to use, modify and distribute this software is granted
alpar@2391
    10
 * provided that this copyright notice appears in all copies. For
alpar@2391
    11
 * precise terms see the accompanying LICENSE file.
alpar@2391
    12
 *
alpar@2391
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@2391
    14
 * express or implied, and with no claim as to its suitability for any
alpar@2391
    15
 * purpose.
alpar@2391
    16
 *
alpar@2391
    17
 */
alpar@2391
    18
athos@1173
    19
/**
athos@1173
    20
\page getstart How to start using LEMON
athos@1173
    21
klao@1519
    22
In this page we detail how to start using LEMON, from downloading it to
klao@1519
    23
your computer, through the steps of installation, to showing a simple
klao@1519
    24
"Hello World" type program that already uses LEMON. We assume that you
klao@1519
    25
have a basic knowledge of your operating system and \c C++ programming
klao@1519
    26
language. The procedure is pretty straightforward, but if you have any
ladanyi@2167
    27
difficulties don't hesitate to <a href="mailto:etik-ol@cs.elte.hu">ask</a>.
athos@1175
    28
ladanyi@1637
    29
athos@1514
    30
\section requirementsLEMON Hardware and software requirements
athos@1175
    31
klao@1519
    32
In LEMON we use C++ templates heavily, thus compilation takes a
klao@1519
    33
considerable amount of time and memory. So some decent box would be
klao@1519
    34
advantageous. But otherwise there are no special hardware requirements.
athos@1514
    35
klao@1519
    36
You will need a recent C++ compiler. Our primary target is the GNU C++
ladanyi@1637
    37
Compiler (g++), from version 3.3 upwards. We also checked the Intel C++
ladanyi@1637
    38
Compiler (icc). Microsoft Visual C++ .NET 2003 was also reported to
klao@1519
    39
work (but not the earlier versions). If you want to develop with LEMON
klao@1519
    40
under Windows you could consider using Cygwin.
athos@1514
    41
ladanyi@1637
    42
In this description we will suppose a Linux environment and GNU C++ Compiler.
athos@1514
    43
ladanyi@1637
    44
ladanyi@1637
    45
\subsection requirementsLP LP solver requirements
ladanyi@1637
    46
ladanyi@1637
    47
The LEMON LP solver interface can use the GLPK (GNU Linear Programming Kit)
ladanyi@1637
    48
and CPLEX solvers (was tested with CPLEX 7.5). If you want to use it you will
ladanyi@1637
    49
need at least one of these. See \ref configureFlags how to enable these at
ladanyi@1637
    50
compile time.
ladanyi@1637
    51
ladanyi@1637
    52
athos@1173
    53
\section downloadLEMON How to download LEMON
athos@1173
    54
athos@1511
    55
You can download LEMON from the LEMON web site:
ladanyi@1637
    56
http://lemon.cs.elte.hu/download.html .
klao@1519
    57
There you will find released versions in form of <tt>.tar.gz</tt> files.
klao@1519
    58
If you want a developer version (for example you want to contribute in
klao@1519
    59
developing the library LEMON) then you might want to use our Subversion
klao@1519
    60
repository. This case is not detailed here, so from now on we suppose that
klao@1519
    61
you downloaded a tar.gz file.
athos@1514
    62
athos@1175
    63
athos@1173
    64
\section installLEMON How to install LEMON
athos@1173
    65
athos@1528
    66
In order to install LEMON you have to do the following steps.
athos@1173
    67
klao@1519
    68
Download the tarball (named <tt>lemon-x.y.z.tar.gz</tt> where \c x,\c y
klao@1519
    69
and \c z are numbers indicating the version of the library: in our example
klao@1519
    70
we will have <tt>lemon-0.3.1.tar.gz</tt>) and issue the following
klao@1519
    71
commands:
athos@1511
    72
klao@1519
    73
\verbatim
athos@1511
    74
tar xvzf lemon-0.3.1.tar.gz
athos@1511
    75
cd lemon-0.3.1
athos@1511
    76
./configure
athos@1511
    77
make
athos@1528
    78
make check   #(This is optional, but recommended. It runs a bunch of tests.)
athos@1511
    79
make install
klao@1519
    80
\endverbatim
athos@1511
    81
klao@1519
    82
These commands install LEMON under \c /usr/local (you will
klao@1519
    83
need root privileges to be able to install to that
klao@1519
    84
directory). If you want to install it to some other place, then
athos@1528
    85
pass the \c --prefix=DIRECTORY flag to \c ./configure, for example:
athos@1528
    86
athos@1528
    87
\verbatim
ladanyi@2167
    88
./configure --prefix=/home/username/lemon
athos@1528
    89
\endverbatim
athos@1528
    90
athos@1528
    91
In what follows we will assume that you were able to install to directory
klao@1519
    92
\c /usr/local, otherwise some extra care is to be taken to use the
klao@1519
    93
library.
athos@1511
    94
athos@1514
    95
We briefly explain these commands below.
athos@1514
    96
klao@1519
    97
\verbatim
athos@1514
    98
tar xvzf lemon-0.3.1.tar.gz
klao@1519
    99
\endverbatim
klao@1519
   100
This command untars the <tt>tar.gz</tt> file into a directory named <tt>
klao@1519
   101
lemon-0.3.1</tt>.
athos@1514
   102
klao@1519
   103
\verbatim
athos@1514
   104
cd lemon-0.3.1
klao@1519
   105
\endverbatim
athos@1514
   106
Enters the directory.
athos@1514
   107
klao@1519
   108
\verbatim
athos@1514
   109
./configure
klao@1519
   110
\endverbatim
athos@1514
   111
Does some configuration (creates makefiles etc).
athos@1514
   112
klao@1519
   113
\verbatim
athos@1514
   114
make
klao@1519
   115
\endverbatim
klao@1519
   116
This command compiles the non-template part of LEMON into
klao@1519
   117
<b>libemon.a</b> file. It also compiles some benchmark and demo
klao@1519
   118
programs.
athos@1514
   119
klao@1519
   120
\verbatim
klao@1519
   121
make check
klao@1519
   122
\endverbatim
klao@1519
   123
This is an optional step: it runs the test programs that we
klao@1519
   124
developed for LEMON to check whether the library works properly on
klao@1519
   125
your platform.
athos@1514
   126
klao@1519
   127
\verbatim
athos@1514
   128
make install
klao@1519
   129
\endverbatim
athos@1514
   130
This will copy the directory structure to its final destination (e.g. to \c
klao@1519
   131
/usr/local) so that your system can access it. This command should
klao@1519
   132
be issued as "root", unless you provided a \c --prefix switch to
ladanyi@1637
   133
the \c configure to install the library in non-default location.
ladanyi@1637
   134
ladanyi@1637
   135
ladanyi@1637
   136
\subsection configureFlags Configure flags
ladanyi@1637
   137
ladanyi@1637
   138
You can pass the following flags to \c ./configure (see \c ./configure --help
ladanyi@1637
   139
for more):
ladanyi@1637
   140
ladanyi@1637
   141
\verbatim
ladanyi@1637
   142
--with-glpk[=PREFIX]
ladanyi@1637
   143
\endverbatim
ladanyi@1637
   144
Enable GLPK support (default). You should specify the prefix too if you
ladanyi@1637
   145
installed it to some non-standard location (e.g. your home directory). If
ladanyi@1637
   146
GLPK is not found, then GLPK support will be disabled.
ladanyi@1637
   147
ladanyi@1637
   148
\verbatim
ladanyi@1637
   149
--with-glpk-includedir=DIR
ladanyi@1637
   150
\endverbatim
ladanyi@1637
   151
The directory where the GLPK header files are located. This is only useful when
alpar@1713
   152
the GLPK headers and libraries are not under the same prefix (which is
alpar@1713
   153
unlikely).
ladanyi@1637
   154
ladanyi@1637
   155
\verbatim
ladanyi@1637
   156
--with-glpk-libdir=DIR
ladanyi@1637
   157
\endverbatim
ladanyi@1637
   158
The directory where the GLPK libraries are located. This is only useful when
alpar@1713
   159
the GLPK headers and libraries are not under the same prefix (which is
alpar@1713
   160
unlikely).
ladanyi@1637
   161
ladanyi@1637
   162
\verbatim
ladanyi@1637
   163
--without-glpk
ladanyi@1637
   164
\endverbatim
ladanyi@1637
   165
Disable GLPK support.
ladanyi@1637
   166
ladanyi@1637
   167
\verbatim
ladanyi@1637
   168
--with-cplex[=PREFIX]
ladanyi@1637
   169
\endverbatim
ladanyi@1637
   170
Enable CPLEX support (default). You should specify the prefix too if you
ladanyi@1637
   171
installed it to some non-standard location (e.g. \c /opt/ilog/cplex75). If
ladanyi@1637
   172
CPLEX is not found, then CPLEX support will be disabled.
ladanyi@1637
   173
ladanyi@1637
   174
\verbatim
ladanyi@1637
   175
--with-cplex-includedir=DIR
ladanyi@1637
   176
\endverbatim
ladanyi@1637
   177
The directory where the CPLEX header files are located. This is only useful
ladanyi@1637
   178
when the CPLEX headers and libraries are not under the same prefix.
ladanyi@1637
   179
ladanyi@1637
   180
\verbatim
ladanyi@1637
   181
--with-cplex-libdir=DIR
ladanyi@1637
   182
\endverbatim
ladanyi@1637
   183
The directory where the CPLEX libraries are located. This is only useful when
ladanyi@1637
   184
the CPLEX headers and libraries are not under the same prefix.
ladanyi@1637
   185
ladanyi@1637
   186
\verbatim
ladanyi@1637
   187
--without-cplex
ladanyi@1637
   188
\endverbatim
ladanyi@1637
   189
Disable CPLEX support.
ladanyi@1637
   190
ladanyi@1637
   191
ladanyi@1637
   192
\section svnCheckout How to checkout LEMON form our Subversion repository
ladanyi@1637
   193
ladanyi@1637
   194
You can obtain the latest version of LEMON from our Subversion repository. To
ladanyi@1637
   195
do this issue the following command:
ladanyi@1637
   196
\verbatim
ladanyi@1637
   197
svn co https://lemon.cs.elte.hu/svn/hugo/trunk lemon
ladanyi@1637
   198
\endverbatim
ladanyi@1637
   199
Use "lemon" as username, the password is empty.
ladanyi@1637
   200
ladanyi@1637
   201
ladanyi@1637
   202
\section svnCompile How to compile the source from the repository
ladanyi@1637
   203
ladanyi@1637
   204
You can compile the code from the repository similarly to the packaged version,
ladanyi@1637
   205
but you will need to run \c ./bootstrap before \c ./configure. See \c
ladanyi@1637
   206
./bootstrap \c --help for options. For bootstrapping you will need the
ladanyi@1637
   207
following tools:
ladanyi@1637
   208
ladanyi@1637
   209
 - <a href="http://www.gnu.org/software/automake/">automake</a> (1.7 or newer)
ladanyi@1637
   210
 - <a href="http://www.gnu.org/software/autoconf/">autoconf</a> (2.59 or newer)
ladanyi@1637
   211
 - <a href="http://www.gnu.org/software/libtool/">libtool</a>
ladanyi@1637
   212
 - <a href="http://pkgconfig.freedesktop.org/">pkgconfig</a>
ladanyi@1637
   213
ladanyi@1637
   214
To generate the documentation, run \c make \c doc. You will need
ladanyi@1637
   215
<a href="http://www.doxygen.org/">Doxygen</a> for this.
ladanyi@1637
   216
ladanyi@1637
   217
You can pass the \c --enable-doc=full flag to \c ./configure to generate the
ladanyi@1637
   218
internal documentation too.
ladanyi@1637
   219
ladanyi@1637
   220
If you pass the \c --disable-doc flag to \c ./configure then the documentation
ladanyi@1637
   221
won't be installed, when you run \c make \c install (this speeds things up a
ladanyi@1637
   222
bit).
athos@1175
   223
athos@1173
   224
\section helloworld My first program using LEMON
athos@1173
   225
klao@1519
   226
If you have installed LEMON on your system you can paste the
klao@1520
   227
following code segment into a file (you can find it as \c
klao@1520
   228
demo/hello_lemon.cc in the LEMON package) to have a first working
klao@1520
   229
program that uses library LEMON.
athos@1173
   230
alpar@1640
   231
\dontinclude hello_lemon.cc
alpar@1640
   232
\skip include
alpar@1640
   233
\until }
athos@1175
   234
athos@1514
   235
First let us briefly explain how this program works.
athos@1175
   236
athos@1175
   237
ListGraph is one of LEMON's graph classes. It is based on linked lists,
athos@1175
   238
therefore iterating throuh its edges and nodes is fast.
athos@1175
   239
alpar@1713
   240
After some convenience typedefs we create a graph and add three nodes to it.
athos@1175
   241
Then we add edges to it to form a complete graph.
athos@1175
   242
athos@1175
   243
Then we iterate through all nodes of the graph. We use a constructor of the
athos@1175
   244
node iterator to initialize it to the first node. The operator++ is used to
athos@1175
   245
step to the next node. Using operator++ on the iterator pointing to the last
athos@1175
   246
node invalidates the iterator i.e. sets its value to
athos@1175
   247
\ref lemon::INVALID "INVALID". This is what we exploit in the stop condition.
athos@1175
   248
athos@1175
   249
We can also iterate through all edges of the graph very similarly. The 
athos@1175
   250
\c target and
athos@1175
   251
\c source member functions can be used to access the endpoints of an edge.
athos@1175
   252
klao@1520
   253
If your installation of LEMON into directory \c /usr/local was
alpar@1713
   254
successful, then it is very easy to compile this program with the
klao@1520
   255
following command (the argument <tt>-lemon</tt> tells the compiler
klao@1520
   256
that we are using the installed library LEMON):
athos@1514
   257
klao@1519
   258
\verbatim
klao@1519
   259
g++ hello_lemon.cc -o hello_lemon -lemon
klao@1519
   260
\endverbatim
klao@1519
   261
klao@1519
   262
As a result you will get the exacutable \c hello_lemon in
athos@1514
   263
this directory that you can run by the command 
klao@1519
   264
\verbatim
klao@1519
   265
./hello_lemon
klao@1519
   266
\endverbatim
athos@1514
   267
athos@1514
   268
klao@1519
   269
If everything has gone well then the previous code fragment prints
klao@1519
   270
out the following:
athos@1175
   271
klao@1519
   272
\verbatim
athos@1175
   273
Nodes: 2 1 0
athos@1175
   274
athos@1175
   275
Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0)
klao@1519
   276
\endverbatim
athos@1175
   277
athos@1514
   278
Congratulations!
athos@1175
   279
klao@1519
   280
If you want to see more features, go to the
klao@1519
   281
\ref quicktour "Quick Tour to LEMON",
klao@1519
   282
if you want to see see some demo programs then go to our 
athos@1175
   283
\ref demoprograms "Demo Programs" page! 
athos@1175
   284
athos@1175
   285
athos@1175
   286
*/