src/work/athos/lp/lp_cplex.h
author alpar
Fri, 08 Apr 2005 06:33:11 +0000
changeset 1321 bc3a4c498eb2
parent 1303 9bcc455da4f5
child 1339 26a88d12d1a6
permissions -rw-r--r--
No output messages by default
athos@1299
     1
/* -*- C++ -*-
athos@1299
     2
 * src/lemon/lp_cplex.h - Part of LEMON, a generic C++ optimization library
athos@1299
     3
 *
athos@1299
     4
 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
athos@1299
     5
 * (Egervary Combinatorial Optimization Research Group, EGRES).
athos@1299
     6
 *
athos@1299
     7
 * Permission to use, modify and distribute this software is granted
athos@1299
     8
 * provided that this copyright notice appears in all copies. For
athos@1299
     9
 * precise terms see the accompanying LICENSE file.
athos@1299
    10
 *
athos@1299
    11
 * This software is provided "AS IS" with no warranty of any kind,
athos@1299
    12
 * express or implied, and with no claim as to its suitability for any
athos@1299
    13
 * purpose.
athos@1299
    14
 *
athos@1299
    15
 */
athos@1299
    16
athos@1299
    17
#ifndef LEMON_LP_CPLEX_H
athos@1299
    18
#define LEMON_LP_CPLEX_H
athos@1299
    19
athos@1299
    20
///\file
athos@1299
    21
///\brief Header of the LEMON-CPLEX lp solver interface.
athos@1299
    22
athos@1319
    23
#include <lemon/lp_base.h>
athos@1299
    24
extern "C" {
athos@1299
    25
#include "ilcplex/cplex.h"
athos@1299
    26
}
athos@1299
    27
athos@1299
    28
namespace lemon {
athos@1299
    29
athos@1299
    30
athos@1299
    31
  /// \brief Wrapper for GLPK solver
athos@1299
    32
  /// 
athos@1299
    33
  /// This class implements a lemon wrapper for GLPK.
athos@1299
    34
  class LpCplex : public LpSolverBase {
athos@1299
    35
athos@1299
    36
  public:
athos@1299
    37
athos@1299
    38
    typedef LpSolverBase Parent;
athos@1299
    39
    
athos@1299
    40
    /// \e
athos@1299
    41
    int status;
athos@1299
    42
    CPXENVptr env;
athos@1299
    43
    CPXLPptr lp;
athos@1299
    44
athos@1299
    45
athos@1299
    46
    /// \e
athos@1299
    47
    LpCplex() : Parent() {
athos@1299
    48
      env = NULL;
athos@1299
    49
      lp = NULL;
athos@1299
    50
      env = CPXopenCPLEXdevelop(&status);     
athos@1299
    51
//     if (Env == NULL)
athos@1299
    52
//     {
athos@1299
    53
//          fprintf(stderr,"A CPLEX környezet megnyitása sikertelen.\n");
athos@1299
    54
// 	 CPXgeterrorstring(Env, Status, ErrorMsg);
athos@1299
    55
// 	 fprintf(stderr,"%s",ErrorMsg);
athos@1299
    56
// 	 goto Terminate;
athos@1299
    57
//     }
athos@1299
    58
athos@1299
    59
    // *** A problema létrehozása ***
athos@1299
    60
    lp = CPXcreateprob(env, &status, "LP problem");
athos@1299
    61
 
athos@1299
    62
//    if (Problem == NULL)
athos@1299
    63
//     {
athos@1299
    64
// 	fprintf(stderr,"Az LP létrehozása sikertelen");
athos@1299
    65
// 	goto Terminate;
athos@1299
    66
//     }
athos@1299
    67
 
athos@1299
    68
    }
athos@1299
    69
    /// \e
athos@1299
    70
    ~LpCplex() {
athos@1299
    71
      status = CPXfreeprob(env,&lp); 
athos@1299
    72
//       if (Status != 0)
athos@1299
    73
// 	{
athos@1299
    74
// 	  fprintf(stderr,"A CPLEX feladat törlése sikertelen.\n");
athos@1299
    75
// 	  CPXgeterrorstring(Env, Status, ErrorMsg);
athos@1299
    76
// 	  fprintf(stderr,"%s",ErrorMsg);
athos@1299
    77
// 	  goto Terminate;
athos@1299
    78
// 	}
athos@1299
    79
       
athos@1299
    80
      status = CPXcloseCPLEX(&env); 
athos@1299
    81
//       if (Status != 0)
athos@1299
    82
// 	{
athos@1299
    83
// 	  fprintf(stderr,"A CPLEX környezet bezárása sikertelen.\n");
athos@1299
    84
// 	  CPXgeterrorstring(Env, Status, ErrorMsg);
athos@1299
    85
// 	  fprintf(stderr,"%s",ErrorMsg);
athos@1299
    86
// 	  goto Terminate;
athos@1299
    87
// 	}
athos@1299
    88
      
athos@1299
    89
    }
athos@1299
    90
athos@1299
    91
  protected:
athos@1299
    92
    virtual int _addCol();
athos@1299
    93
    virtual int _addRow();
athos@1299
    94
    virtual void _setRowCoeffs(int i, 
athos@1299
    95
			       int length,
athos@1299
    96
                               const int   * indices, 
athos@1299
    97
                               const Value   * values );
athos@1299
    98
    virtual void _setColCoeffs(int i, 
athos@1299
    99
			       int length,
athos@1299
   100
                               const int   * indices, 
athos@1299
   101
                               const Value   * values);
athos@1299
   102
    virtual void _setColLowerBound(int i, Value value);
athos@1299
   103
    virtual void _setColUpperBound(int i, Value value);
athos@1299
   104
    virtual void _setRowLowerBound(int i, Value value);
athos@1299
   105
    virtual void _setRowUpperBound(int i, Value value);
athos@1299
   106
    virtual void _setObjCoeff(int i, Value obj_coef);
athos@1299
   107
    ///\e
athos@1299
   108
    
athos@1299
   109
    ///\bug Unimplemented
athos@1299
   110
    ///
athos@1319
   111
    virtual SolveExitStatus _solve();
athos@1319
   112
    ///\e
athos@1319
   113
athos@1319
   114
    ///\bug Unimplemented
athos@1319
   115
    ///
athos@1319
   116
    virtual Value _getPrimal(int i);
athos@1299
   117
    ///\e
athos@1299
   118
    
athos@1299
   119
    ///\bug Unimplemented
athos@1299
   120
    ///
athos@1319
   121
    virtual Value _getPrimalValue();
athos@1319
   122
    ///\e
athos@1319
   123
    
athos@1319
   124
    ///\bug Unimplemented
athos@1319
   125
    ///
athos@1319
   126
    virtual SolutionStatus _getPrimalStatus();
athos@1319
   127
athos@1319
   128
    ///\e
athos@1319
   129
    
athos@1319
   130
    ///\bug Unimplemented
athos@1319
   131
    ///
athos@1319
   132
    virtual void _setMax();
athos@1319
   133
    ///\e
athos@1319
   134
    
athos@1319
   135
    ///\bug Unimplemented
athos@1319
   136
    ///
athos@1319
   137
    virtual void _setMin();
athos@1299
   138
athos@1299
   139
  };
athos@1299
   140
} //END OF NAMESPACE LEMON
athos@1299
   141
athos@1299
   142
#endif //LEMON_LP_CPLEX_H
athos@1299
   143