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