00001 // Definitions for handling return codes and messages of local optimization IEs -*- C++ -*- 00002 00003 // $Id: termreason.h 347 2008-02-06 15:20:01Z schilly $ 00004 // Copyright (C) 2008 Mihaly Csaba Markot 00005 // 00006 // This file is part of the COCONUT API. This library 00007 // is free software; you can redistribute it and/or modify it under the 00008 // terms of the Library GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // Library GNU General Public License for more details. 00016 00017 // As a special exception, you may use this file as part of a free software 00018 // library without restriction. Specifically, if other files instantiate 00019 // templates or use macros or inline functions from this file, or you compile 00020 // this file and link it with other files to produce an executable, this 00021 // file does not by itself cause the resulting executable to be covered by 00022 // the Library GNU General Public License. This exception does not however 00023 // invalidate any other reasons why the executable file might be covered by 00024 // the Library GNU General Public License. 00025 00028 #include <locopt_ret.h> 00029 00030 namespace coco { 00031 00032 // determines IE return weight associated to the solver return value srval 00033 // from the ret_info map 00034 double get_locopt_weight_from_rval(const locopt_ret& ret_info, 00035 const std::string& iename, const int srval) 00036 { 00037 locopt_ret::const_iterator it = ret_info.find(srval); 00038 if (it == ret_info.end()) 00039 throw inference_engine_exception( 00040 std::string("COCO-") + iename + 00041 std::string(": Unknown solver return code - Contact the " 00042 "COCONUT developers for an update of the ") 00043 + iename + std::string(" solver interface!")); 00044 return it->second.get_weight(); 00045 } 00046 00047 // determines IE termination reason associated to the solver return value srval 00048 // from the ret_info map 00049 termination_reason get_locopt_termr_from_rval(const locopt_ret& ret_info, 00050 const std::string& iename, const int srval) 00051 { 00052 locopt_ret::const_iterator it = ret_info.find(srval); 00053 if (it == ret_info.end()) 00054 throw inference_engine_exception( 00055 std::string("COCO-") + iename + 00056 std::string(": Unknown solver return code - Contact the " 00057 "COCONUT developers for an update of the ") 00058 + iename + std::string(" solver interface!")); 00059 00060 if (it->second.get_code() == LOPT_SUCCESS) 00061 return termination_reason(); // generate a uniform message "SUCCESS" and 00062 // a uniform 0 return value 00063 else 00064 return it->second.get_termr(); 00065 } 00066 00067 } // namespace coco