lemon/mip_glpk.cc
author athos
Mon, 17 Jul 2006 09:31:41 +0000
changeset 2147 63d293ff1bef
child 2148 ab368e0ab662
permissions -rw-r--r--
mip_test file went to mip_demo.
     1 /* -*- C++ -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     4  *
     5  * Copyright (C) 2003-2006
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    11  * precise terms see the accompanying LICENSE file.
    12  *
    13  * This software is provided "AS IS" with no warranty of any kind,
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    16  *
    17  */
    18 
    19 #ifndef LEMON_ILP_GLPK_CC
    20 #define LEMON_ILP_GLPK_CC
    21 
    22 ///\file
    23 ///\brief Implementation of the LEMON-GLPK lp solver interface.
    24 
    25 #include <lemon/mip_glpk.h>
    26 
    27 namespace lemon {
    28   
    29   MipGlpk::MipGlpk() {
    30     lpx_set_class(lp,LPX_MIP);
    31   }
    32   
    33   void MipGlpk::_integer(int i, bool enable){
    34     if(enable){
    35       lpx_set_col_kind(lp,i,LPX_IV);
    36     }else{
    37       lpx_set_col_kind(lp,i,LPX_CV);
    38     }
    39   }
    40   
    41   bool MipGlpk::_integer(int i){
    42     if(LPX_IV == lpx_get_col_kind(lp,i)){
    43       return true;
    44     }
    45     return false;
    46   }
    47   
    48   LpGlpk::SolveExitStatus MipGlpk::_solve(){
    49     int result = lpx_simplex(lp);
    50     result = lpx_integer(lp);
    51     switch (result){
    52       case LPX_E_OBJLL:
    53       case LPX_E_OBJUL:
    54       case LPX_E_ITLIM:
    55       case LPX_E_TMLIM:
    56       case LPX_E_OK:
    57         return SOLVED;
    58       default:
    59         return UNSOLVED;
    60     }
    61   }
    62   
    63   MipGlpk::Value MipGlpk::_getPrimal(int i){
    64     return lpx_mip_col_val(lp,i);
    65   }
    66   
    67   MipGlpk::Value MipGlpk::_getPrimalValue(){
    68     return lpx_mip_obj_val(lp);
    69   }
    70 } //END OG NAMESPACE LEMON
    71 
    72 #endif