mt_cutpool.h

Go to the documentation of this file.
00001 /* MTgomory "multi tableau gomory cut" provides an implementation for gomory
00002  * cuts derived from multiple tableau rows in the spirit of the work of
00003  * Andersen et al (IPCO 2007), Cornuejols (es presented in George Nemhauser
00004  * Birthday Conference in Atlanta 2007) and Gomory (presented in the same
00005  * conference).
00006  *
00007  * Copyright (C) 2007 Daniel Espinoza.
00008  * 
00009  * This library is free software; you can redistribute it and/or modify it
00010  * under the terms of the GNU Lesser General Public License as published by the
00011  * Free Software Foundation; either version 2.1 of the License, or (at your
00012  * option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but 
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
00016  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
00017  * License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with this library; if not, write to the Free Software Foundation,
00021  * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
00022  * */
00023 /* ========================================================================= */
00024 #ifndef __MT_CUTPOOL_H__
00025 #define __MT_CUTPOOL_H__
00026 #include "EGlib.h"
00027 #include "mt_gomory.h"
00028 #include "mt_types.h"
00029 #include "mt_cplex_cbk.h"
00030 /** @file 
00031  * @ingroup MTgomory */
00032 /** @addtogroup MTgomory */
00033 /** @{ */
00034 /* ========================================================================= */
00035 /** @brief initialize a cut structure 
00036  * @param __cut pointer to an #MTcut_t structure 
00037  * */
00038 #define MTcut_init(__cut) memset(__cut,0,sizeof(MTcut_t))
00039 /* ========================================================================= */
00040 /** @brief resize a cut structure
00041  * @param MTcut pointer to an #MTcut_t structure 
00042  * @param MTnsz new space for the cut */
00043 void MTcut_rsz(MTcut_t*const MTcut, const int MTnsz);
00044 /* ========================================================================= */
00045 /** @brief free any internal memory asociated with an #MTcut_t structure 
00046  * @param MTcut pointer to an #MTcut_t structure 
00047  * */
00048 void MTcut_clear(MTcut_t*const MTcut);
00049 /* ========================================================================= */
00050 /** @brief initialize an #MTcutHeapCn_t structure */
00051 #define MTcutHeapCnInit(__chcn) do{\
00052   MTcutHeapCn_t*const __MTchcn = (__chcn);\
00053   dbl_EGeHeapCnInit(&(__MTchcn->hcn));\
00054   MTcut_init(&(__MTchcn->cut));}while(0)
00055 /* ========================================================================= */
00056 /** @brief clear all internally allocated memory */
00057 #define MTcutHeapCnClear(__chcn) do{\
00058   MTcutHeapCn_t*const __MTchcn = (__chcn);\
00059   dbl_EGeHeapCnClear(&(__MTchcn->hcn));\
00060   MTcut_clear(&(__MTchcn->cut));}while(0)
00061 /* ========================================================================= */
00062 /** @brief set the dominance strategy */
00063 #define MTcutHeapSetDominance(__cuth,__dom) ((__cuth)->control.dominance_check = (__dom))
00064 /* ========================================================================= */
00065 /** @brief set the cutselection strategy */
00066 #define MTcutHeapSetCS(__cuth,__cutsel) ((__cuth)->control.cut_score = (__cutsel))
00067 /* ========================================================================= */
00068 /** @brief return a pointer to the next free #MTcut_t structure in the set 
00069  * @param __cuth structure to initialize
00070  * */
00071 #define MTcutHeap_get_free_cut(__cuth) ((__cuth)->next_free)
00072 /* ========================================================================= */
00073 /** @brief initialize an #MTcutHeap_t structure 
00074  * @param cuth structure to initialize
00075  * @param sz how many cuts to store 
00076  * */
00077 void MTcutHeapInit(MTcutHeap_t*const cuth,size_t sz);
00078 /* ========================================================================= */
00079 /** @brief Clear any internal memory asociated with an #MTcutHeap_t structure.
00080  * Note that after a call to this function a new call to #MTcutHeapInit should
00081  * be made before using any other function over the strucutre 
00082  * @param cuth structure to clear 
00083  * */
00084 void MTcutHeapClear(MTcutHeap_t*const cuth);
00085 /* ========================================================================= */
00086 /** @brief add the cut (obtained by #MTcutHeap_get_free_cut) to the structure,
00087  * and possibly discard a worst cut from the heap 
00088  * @param cuth structure where we perform the operation
00089  * @return zero on success, non-zero otherwise.
00090  * */
00091 int MTcutHeap_add_cut(const MTlp_t*const lp, MTcutHeap_t*const cuth);
00092 /* ========================================================================= */
00093 /** @brief pop the worst remaining cut within an #MTcutHeap_t structure. 
00094  * Note that the memory asociated with the returned #MTcut_t structure is
00095  * handled by the #MTcutHeap_t structure, and should not be freed by the user.
00096  * @param cuth structure where we perform the operation
00097  * @return pointer to the worst #MTcut_t structure (acording to the socre
00098  * function selected) still in the heap, NULL if no more cuts are left.
00099  * */
00100 MTcut_t* MTcutHeap_pop_cut(MTcutHeap_t*const cuth);
00101 /* ========================================================================= */
00102 /** @brief return the number of stored cuts in the given #MTcutHeap_t
00103  * structure. 
00104  * @param __cuth structure where we perform the operation
00105  * @return the number of cuts in the given #MTcutHeap_t structure.
00106  * */
00107 #define MTcutHeap_get_ncuts(__cuth) (__cuth->heap.sz)
00108 /* ========================================================================= */
00109 /** @brief check for dominance between cuts.
00110  * @param cut1 First cut to compare 
00111  * @param cut2 Second cut to compare
00112  * @return zero if neither dominates the other. 1 if cut1 dominates cut2, -1
00113  * if cut2 dominates cut1. 
00114  * */
00115 int MTcut_check_dominance(const MTcut_t*const cut1, const MTcut_t*const cut2);
00116 /* ========================================================================= */
00117 /** @brief copy a cut from one structure to the next 
00118  * @param orig cut to copy
00119  * @param dest where to copy the cut, all previous information will be lost.
00120  * */
00121 void MTcut_copy(MTcut_t*const dest,const MTcut_t*const src);
00122 /** @} */
00123 /* end of mt_cutpool.h */
00124 /* ========================================================================= */
00125 #endif

Generated on Mon Oct 26 09:16:29 2009 for MTgomory by  doxygen 1.4.6