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@2148: athos@2149: void MipGlpk::_colType(int i, MipGlpk::ColTypes col_type){ athos@2148: switch (col_type){ athos@2148: case INTEGER: athos@2148: lpx_set_col_kind(lp,i,LPX_IV); athos@2148: break; athos@2148: case REAL: athos@2148: lpx_set_col_kind(lp,i,LPX_CV); athos@2148: break; athos@2149: default:; athos@2148: //FIXME problem athos@2144: } athos@2144: } athos@2144: athos@2149: MipGlpk::ColTypes MipGlpk::_colType(int i){ athos@2148: switch (lpx_get_col_kind(lp,i)){ athos@2148: case LPX_IV: athos@2148: return INTEGER;//Or binary athos@2148: case LPX_CV: athos@2148: return REAL; athos@2148: default: athos@2148: return REAL;//Error! athos@2144: } athos@2148: 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