athos@1299: /* -*- C++ -*-
athos@1299:  * src/lemon/lp_cplex.h - Part of LEMON, a generic C++ optimization library
athos@1299:  *
athos@1299:  * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
athos@1299:  * (Egervary Combinatorial Optimization Research Group, EGRES).
athos@1299:  *
athos@1299:  * Permission to use, modify and distribute this software is granted
athos@1299:  * provided that this copyright notice appears in all copies. For
athos@1299:  * precise terms see the accompanying LICENSE file.
athos@1299:  *
athos@1299:  * This software is provided "AS IS" with no warranty of any kind,
athos@1299:  * express or implied, and with no claim as to its suitability for any
athos@1299:  * purpose.
athos@1299:  *
athos@1299:  */
athos@1299: 
athos@1299: #ifndef LEMON_LP_CPLEX_H
athos@1299: #define LEMON_LP_CPLEX_H
athos@1299: 
athos@1299: ///\file
athos@1299: ///\brief Header of the LEMON-CPLEX lp solver interface.
athos@1299: 
athos@1319: #include <lemon/lp_base.h>
athos@1299: extern "C" {
athos@1339: #include <ilcplex/cplex.h>
athos@1299: }
athos@1299: 
athos@1299: namespace lemon {
athos@1299: 
athos@1299: 
athos@1299:   /// \brief Wrapper for GLPK solver
athos@1299:   /// 
athos@1299:   /// This class implements a lemon wrapper for GLPK.
athos@1299:   class LpCplex : public LpSolverBase {
athos@1299: 
athos@1299:   public:
athos@1299: 
athos@1299:     typedef LpSolverBase Parent;
athos@1299:     
athos@1299:     /// \e
athos@1299:     int status;
athos@1299:     CPXENVptr env;
athos@1299:     CPXLPptr lp;
athos@1299: 
athos@1299: 
athos@1299:     /// \e
athos@1299:     LpCplex() : Parent() {
athos@1299:       env = NULL;
athos@1299:       lp = NULL;
athos@1299:       env = CPXopenCPLEXdevelop(&status);     
athos@1299: //     if (Env == NULL)
athos@1299: //     {
athos@1299: //          fprintf(stderr,"A CPLEX környezet megnyitása sikertelen.\n");
athos@1299: // 	 CPXgeterrorstring(Env, Status, ErrorMsg);
athos@1299: // 	 fprintf(stderr,"%s",ErrorMsg);
athos@1299: // 	 goto Terminate;
athos@1299: //     }
athos@1299: 
athos@1299:     // *** A problema létrehozása ***
athos@1299:     lp = CPXcreateprob(env, &status, "LP problem");
athos@1299:  
athos@1299: //    if (Problem == NULL)
athos@1299: //     {
athos@1299: // 	fprintf(stderr,"Az LP létrehozása sikertelen");
athos@1299: // 	goto Terminate;
athos@1299: //     }
athos@1299:  
athos@1299:     }
athos@1299:     /// \e
athos@1299:     ~LpCplex() {
athos@1299:       status = CPXfreeprob(env,&lp); 
athos@1299: //       if (Status != 0)
athos@1299: // 	{
athos@1299: // 	  fprintf(stderr,"A CPLEX feladat törlése sikertelen.\n");
athos@1299: // 	  CPXgeterrorstring(Env, Status, ErrorMsg);
athos@1299: // 	  fprintf(stderr,"%s",ErrorMsg);
athos@1299: // 	  goto Terminate;
athos@1299: // 	}
athos@1299:        
athos@1299:       status = CPXcloseCPLEX(&env); 
athos@1299: //       if (Status != 0)
athos@1299: // 	{
athos@1299: // 	  fprintf(stderr,"A CPLEX környezet bezárása sikertelen.\n");
athos@1299: // 	  CPXgeterrorstring(Env, Status, ErrorMsg);
athos@1299: // 	  fprintf(stderr,"%s",ErrorMsg);
athos@1299: // 	  goto Terminate;
athos@1299: // 	}
athos@1299:       
athos@1299:     }
athos@1299: 
athos@1299:   protected:
athos@1299:     virtual int _addCol();
athos@1299:     virtual int _addRow();
athos@1299:     virtual void _setRowCoeffs(int i, 
athos@1299: 			       int length,
athos@1299:                                const int   * indices, 
athos@1299:                                const Value   * values );
athos@1299:     virtual void _setColCoeffs(int i, 
athos@1299: 			       int length,
athos@1299:                                const int   * indices, 
athos@1299:                                const Value   * values);
athos@1299:     virtual void _setColLowerBound(int i, Value value);
athos@1299:     virtual void _setColUpperBound(int i, Value value);
athos@1299:     virtual void _setRowLowerBound(int i, Value value);
athos@1299:     virtual void _setRowUpperBound(int i, Value value);
athos@1299:     virtual void _setObjCoeff(int i, Value obj_coef);
athos@1299:     ///\e
athos@1299:     
athos@1299:     ///\bug Unimplemented
athos@1299:     ///
athos@1319:     virtual SolveExitStatus _solve();
athos@1319:     ///\e
athos@1319: 
athos@1319:     ///\bug Unimplemented
athos@1319:     ///
athos@1319:     virtual Value _getPrimal(int i);
athos@1299:     ///\e
athos@1299:     
athos@1299:     ///\bug Unimplemented
athos@1299:     ///
athos@1319:     virtual Value _getPrimalValue();
athos@1319:     ///\e
athos@1319:     
athos@1319:     ///\bug Unimplemented
athos@1319:     ///
athos@1319:     virtual SolutionStatus _getPrimalStatus();
athos@1319: 
athos@1319:     ///\e
athos@1319:     
athos@1319:     ///\bug Unimplemented
athos@1319:     ///
athos@1319:     virtual void _setMax();
athos@1319:     ///\e
athos@1319:     
athos@1319:     ///\bug Unimplemented
athos@1319:     ///
athos@1319:     virtual void _setMin();
athos@1299: 
athos@1299:   };
athos@1299: } //END OF NAMESPACE LEMON
athos@1299: 
athos@1299: #endif //LEMON_LP_CPLEX_H
athos@1299: