demo/lp_demo.cc
changeset 1577 15098fb5275c
parent 1530 d99c3c84f797
child 1610 893dacc1866c
     1.1 --- a/demo/lp_demo.cc	Wed Jul 20 16:03:41 2005 +0000
     1.2 +++ b/demo/lp_demo.cc	Wed Jul 20 16:05:04 2005 +0000
     1.3 @@ -1,3 +1,29 @@
     1.4 +/* -*- C++ -*-
     1.5 + * demo/graph_to_eps.cc - Part of LEMON, a generic C++ optimization library
     1.6 + *
     1.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     1.8 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
     1.9 + *
    1.10 + * Permission to use, modify and distribute this software is granted
    1.11 + * provided that this copyright notice appears in all copies. For
    1.12 + * precise terms see the accompanying LICENSE file.
    1.13 + *
    1.14 + * This software is provided "AS IS" with no warranty of any kind,
    1.15 + * express or implied, and with no claim as to its suitability for any
    1.16 + * purpose.
    1.17 + *
    1.18 + */
    1.19 +
    1.20 +/// \ingroup demos
    1.21 +/// \file
    1.22 +/// \brief A program demonstrating the LEMON LP solver interface
    1.23 +///
    1.24 +/// This program is a simple application of the LEMON LP solver
    1.25 +/// interface: we formulate a linear programming (LP) problem and then
    1.26 +/// solve it using the underlying solver (GLPK or CPLEX for
    1.27 +/// example). For the detailed documentation of the LEMON LP solver
    1.28 +/// interface read \ref lemon::LpSolverBase "this".
    1.29 +
    1.30  #ifdef HAVE_CONFIG_H
    1.31  #include <config.h>
    1.32  #endif
    1.33 @@ -13,10 +39,14 @@
    1.34  
    1.35  using namespace lemon;
    1.36  
    1.37 +
    1.38 +
    1.39  #ifdef HAVE_GLPK
    1.40  typedef LpGlpk LpDefault;
    1.41 +const char default_solver_name[]="GLPK";
    1.42  #elif HAVE_CPLEX
    1.43  typedef LpCplex LpDefault;
    1.44 +const char default_solver_name[]="CPLEX";
    1.45  #endif
    1.46  
    1.47  int main()
    1.48 @@ -30,6 +60,9 @@
    1.49    typedef LpDefault::Col Col;
    1.50    
    1.51  
    1.52 +  std::cout<<"A program demonstrating the LEMON LP solver interface"<<std::endl; 
    1.53 +  std::cout<<"Solver used: "<<default_solver_name<<std::endl;
    1.54 +
    1.55    //This will be a maximization
    1.56    lp.max();
    1.57  
    1.58 @@ -54,7 +87,8 @@
    1.59  
    1.60    //Print results
    1.61    if (lp.primalStatus()==LpSolverBase::OPTIMAL){
    1.62 -    printf("Z = %g; x1 = %g; x2 = %g; x3 = %g\n", 
    1.63 +    std::cout<<"Optimal solution found!"<<std::endl;
    1.64 +    printf("optimum value = %g; x1 = %g; x2 = %g; x3 = %g\n", 
    1.65  	   lp.primalValue(), 
    1.66  	   lp.primal(x1), lp.primal(x2), lp.primal(x3));
    1.67    }