src/work/athos/lp/lp_cplex.h
changeset 1299 e2545ef5d7d8
child 1303 9bcc455da4f5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/athos/lp/lp_cplex.h	Mon Apr 04 14:46:08 2005 +0000
     1.3 @@ -0,0 +1,122 @@
     1.4 +/* -*- C++ -*-
     1.5 + * src/lemon/lp_cplex.h - Part of LEMON, a generic C++ optimization library
     1.6 + *
     1.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     1.8 + * (Egervary Combinatorial Optimization Research Group, 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 +#ifndef LEMON_LP_CPLEX_H
    1.21 +#define LEMON_LP_CPLEX_H
    1.22 +
    1.23 +///\file
    1.24 +///\brief Header of the LEMON-CPLEX lp solver interface.
    1.25 +
    1.26 +#include "lp_base.h"
    1.27 +extern "C" {
    1.28 +#include "ilcplex/cplex.h"
    1.29 +}
    1.30 +
    1.31 +namespace lemon {
    1.32 +
    1.33 +
    1.34 +  /// \brief Wrapper for GLPK solver
    1.35 +  /// 
    1.36 +  /// This class implements a lemon wrapper for GLPK.
    1.37 +  class LpCplex : public LpSolverBase {
    1.38 +
    1.39 +  public:
    1.40 +
    1.41 +    typedef LpSolverBase Parent;
    1.42 +    
    1.43 +    /// \e
    1.44 +    int status;
    1.45 +    CPXENVptr env;
    1.46 +    CPXLPptr lp;
    1.47 +
    1.48 +
    1.49 +    /// \e
    1.50 +    LpCplex() : Parent() {
    1.51 +      env = NULL;
    1.52 +      lp = NULL;
    1.53 +      env = CPXopenCPLEXdevelop(&status);     
    1.54 +//     if (Env == NULL)
    1.55 +//     {
    1.56 +//          fprintf(stderr,"A CPLEX környezet megnyitása sikertelen.\n");
    1.57 +// 	 CPXgeterrorstring(Env, Status, ErrorMsg);
    1.58 +// 	 fprintf(stderr,"%s",ErrorMsg);
    1.59 +// 	 goto Terminate;
    1.60 +//     }
    1.61 +
    1.62 +    // *** A problema létrehozása ***
    1.63 +    lp = CPXcreateprob(env, &status, "LP problem");
    1.64 + 
    1.65 +//    if (Problem == NULL)
    1.66 +//     {
    1.67 +// 	fprintf(stderr,"Az LP létrehozása sikertelen");
    1.68 +// 	goto Terminate;
    1.69 +//     }
    1.70 + 
    1.71 +    }
    1.72 +    /// \e
    1.73 +    ~LpCplex() {
    1.74 +      status = CPXfreeprob(env,&lp); 
    1.75 +//       if (Status != 0)
    1.76 +// 	{
    1.77 +// 	  fprintf(stderr,"A CPLEX feladat törlése sikertelen.\n");
    1.78 +// 	  CPXgeterrorstring(Env, Status, ErrorMsg);
    1.79 +// 	  fprintf(stderr,"%s",ErrorMsg);
    1.80 +// 	  goto Terminate;
    1.81 +// 	}
    1.82 +       
    1.83 +      status = CPXcloseCPLEX(&env); 
    1.84 +//       if (Status != 0)
    1.85 +// 	{
    1.86 +// 	  fprintf(stderr,"A CPLEX környezet bezárása sikertelen.\n");
    1.87 +// 	  CPXgeterrorstring(Env, Status, ErrorMsg);
    1.88 +// 	  fprintf(stderr,"%s",ErrorMsg);
    1.89 +// 	  goto Terminate;
    1.90 +// 	}
    1.91 +      
    1.92 +    }
    1.93 +
    1.94 +  protected:
    1.95 +    virtual int _addCol();
    1.96 +    virtual int _addRow();
    1.97 +    virtual void _setRowCoeffs(int i, 
    1.98 +			       int length,
    1.99 +                               const int   * indices, 
   1.100 +                               const Value   * values );
   1.101 +    virtual void _setColCoeffs(int i, 
   1.102 +			       int length,
   1.103 +                               const int   * indices, 
   1.104 +                               const Value   * values);
   1.105 +    virtual void _setColLowerBound(int i, Value value);
   1.106 +    virtual void _setColUpperBound(int i, Value value);
   1.107 +    virtual void _setRowLowerBound(int i, Value value);
   1.108 +    virtual void _setRowUpperBound(int i, Value value);
   1.109 +    virtual void _setObjCoeff(int i, Value obj_coef);
   1.110 +    ///\e
   1.111 +    
   1.112 +    ///\bug Unimplemented
   1.113 +    ///
   1.114 +    virtual SolutionType _solve();
   1.115 +    ///\e
   1.116 +    
   1.117 +    ///\bug Unimplemented
   1.118 +    ///
   1.119 +    virtual Value _getSolution(int i);
   1.120 +
   1.121 +  };
   1.122 +} //END OF NAMESPACE LEMON
   1.123 +
   1.124 +#endif //LEMON_LP_CPLEX_H
   1.125 +