athos@2144: /* -*- C++ -*- athos@2144: * athos@2144: * This file is a part of LEMON, a generic C++ optimization library athos@2144: * athos@2144: * Copyright (C) 2003-2006 athos@2144: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport athos@2144: * (Egervary Research Group on Combinatorial Optimization, EGRES). athos@2144: * athos@2144: * Permission to use, modify and distribute this software is granted athos@2144: * provided that this copyright notice appears in all copies. For athos@2144: * precise terms see the accompanying LICENSE file. athos@2144: * athos@2144: * This software is provided "AS IS" with no warranty of any kind, athos@2144: * express or implied, and with no claim as to its suitability for any athos@2144: * purpose. athos@2144: * athos@2144: */ athos@2144: athos@2144: #ifndef LEMON_ILP_GLPK_CC athos@2144: #define LEMON_ILP_GLPK_CC athos@2144: athos@2144: ///\file athos@2144: ///\brief Implementation of the LEMON-GLPK lp solver interface. athos@2144: athos@2144: #include athos@2144: athos@2144: namespace lemon { athos@2144: athos@2144: MipGlpk::MipGlpk() { athos@2144: lpx_set_class(lp,LPX_MIP); athos@2144: } athos@2144: athos@2144: void MipGlpk::_integer(int i, bool enable){ athos@2144: if(enable){ athos@2144: lpx_set_col_kind(lp,i,LPX_IV); athos@2144: }else{ athos@2144: lpx_set_col_kind(lp,i,LPX_CV); athos@2144: } athos@2144: } athos@2144: athos@2144: bool MipGlpk::_integer(int i){ athos@2144: if(LPX_IV == lpx_get_col_kind(lp,i)){ athos@2144: return true; athos@2144: } athos@2144: return false; athos@2144: } athos@2144: athos@2144: LpGlpk::SolveExitStatus MipGlpk::_solve(){ athos@2144: int result = lpx_simplex(lp); athos@2144: result = lpx_integer(lp); athos@2144: switch (result){ athos@2144: case LPX_E_OBJLL: athos@2144: case LPX_E_OBJUL: athos@2144: case LPX_E_ITLIM: athos@2144: case LPX_E_TMLIM: athos@2144: case LPX_E_OK: athos@2144: return SOLVED; athos@2144: default: athos@2144: return UNSOLVED; athos@2144: } athos@2144: } athos@2144: athos@2144: MipGlpk::Value MipGlpk::_getPrimal(int i){ athos@2144: return lpx_mip_col_val(lp,i); athos@2144: } athos@2144: athos@2144: MipGlpk::Value MipGlpk::_getPrimalValue(){ athos@2144: return lpx_mip_obj_val(lp); athos@2144: } athos@2144: } //END OG NAMESPACE LEMON athos@2144: athos@2144: #endif