/* -*- 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::_integer(int i, bool enable){ if(enable){ lpx_set_col_kind(lp,i,LPX_IV); }else{ lpx_set_col_kind(lp,i,LPX_CV); } } bool MipGlpk::_integer(int i){ if(LPX_IV == lpx_get_col_kind(lp,i)){ return true; } return false; } 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