Dip  0.92.4
sym_tm.h
Go to the documentation of this file.
1 /*===========================================================================*/
2 /* */
3 /* This file is part of the SYMPHONY MILP Solver Framework. */
4 /* */
5 /* SYMPHONY was jointly developed by Ted Ralphs (ted@lehigh.edu) and */
6 /* Laci Ladanyi (ladanyi@us.ibm.com). */
7 /* */
8 /* (c) Copyright 2000-2019 Ted Ralphs. All Rights Reserved. */
9 /* */
10 /* This software is licensed under the Eclipse Public License. Please see */
11 /* accompanying file for terms. */
12 /* */
13 /*===========================================================================*/
14 
15 #ifndef _TREE_MANAGER
16 #define _TREE_MANAGER
17 
18 #define COMPILING_FOR_TM
19 
20 #include "symphony.h"
21 #include "sym_tm_params.h"
22 #include "sym_types.h"
23 #ifdef COMPILE_IN_CG
24 #include "sym_cg.h"
25 #endif
26 #ifdef COMPILE_IN_CP
27 #include "sym_cp.h"
28 #endif
29 
30 /*===========================================================================*/
31 
32 typedef struct PROCESS_SET{
33  int procnum; /* the number of processes spawned */
34  int *procs; /* the tid's of the processes */
35  int free_num; /* how many of them are free */
36  int *free_ind; /* the indices of the free ones */
38 
39 /*===========================================================================*/
40 
41 typedef struct TM_TEMP{
42  int *i;
43  int i_size;
44  char *c;
45  int c_size;
46  double *d;
47  int d_size;
48 }tm_temp;
49 
50 /*===========================================================================*\
51  * Problem data structure
52 \*===========================================================================*/
53 
54 struct LP_PROB;
55 
56 typedef struct TM_PROB{
58  int master;
59  int has_ub;
61  double start_time;
62  double ub; /* the best global upper bound found */
63  double lb; /* the best global lower bound known */
64  double printed_lb; /* the lower bound we print for user */
66  double obj_offset; /* constant to be added to the objective value*/
67  char obj_sense; /* objective sense*/
68  double ub_estimate;
69  int termcode;
70  int *termcodes;
74 
75 #ifdef COMPILE_IN_LP
76  struct LP_PROB **lpp;
77  int opt_thread_num;
78 #ifdef COMPILE_IN_CG
79  cg_prob **cgp;
80 #endif
81 #endif
82 #ifdef COMPILE_IN_CP
83  cut_pool **cpp;
84 #endif
85 
86  int *nodes_per_cp; /* for each cut_pool it contains how
87  many nodes are assigned to it */
88  int *active_nodes_per_cp; /* same for active_nodes */
89 
91 
92  int bvarnum; /* number of base variables */
93  int bcutnum; /* number of base constraints */
94 
95  int phase; /* the current phase */
96 
98  bc_node **active_nodes; /* contains a list of the nodes
99  currently being processed */
100 
101  int samephase_candnum; /* nodes still to be processed in */
102  bc_node **samephase_cand; /* the current phase */
104 
105  int nextphase_candnum; /* nodes to be processed next phase*/
108 
109  /* The list of cuts that were active in at least one search tree node */
110  int cut_num;
113 
115 
116  node_times comp_times; /* keeps track of the computation times
117  for the problem */
120 
121  /* pseudo costs and reliability measures */
122  double *pcost_down;
123  double *pcost_up;
125  int *br_rel_up;
127  int *br_inf_up;
132 
133  double *var_rank;
135  double *root_lp;
136 
137 
138  /* some temporary stuff */
143 
144 #ifdef TRACE_PATH
145  int feas_sol_size;
146  int *feas_sol;
147 #endif
148 
150  /* solution pool */
152 }tm_prob;
153 
154 /*===========================================================================*/
155 /*==================== TM basic functions (tm_func.c) =======================*/
156 /*===========================================================================*/
157 
158 int tm_initialize PROTO((tm_prob *tm, base_desc *base,
159  node_desc *root_desc));
160 int solve PROTO((tm_prob *tm));
161 void print_tree_status PROTO((tm_prob *tm));
162 void calculate_widths PROTO((bc_node *node, int *widths));
163 int start_node PROTO((tm_prob *tm, int thread_num));
164 bc_node *del_best_node PROTO((tm_prob *tm));
165 void insert_new_node PROTO((tm_prob *tm, bc_node *new_node));
166 int node_compar PROTO((tm_prob * tm, int rule, bc_node *node0, bc_node *node1));
167 int assign_pool PROTO((tm_prob *tm, int oldpool, process_set *pools,
168  int *active_nodes_per_pool, int *nodes_per_pool));
169 int generate_children PROTO((tm_prob *tm, bc_node *node, branch_obj *bobj,
170  double *objval, int *feasible, char *action,
171  int olddive, int *keep, int new_branching_cut));
172 char shall_we_dive PROTO((tm_prob *tm, double objval));
173 int purge_pruned_nodes PROTO((tm_prob *tm, bc_node *node, int category));
174 int find_process_index PROTO((process_set *pset, int tid));
175 void mark_lp_process_free PROTO((tm_prob *tm, int lp, int cp));
176 int add_cut_to_list PROTO((tm_prob *tm, cut_data *cut));
177 void install_new_ub PROTO((tm_prob *tm, double new_ub, int opt_thread_num,
178  int bc_index, char branching, int feasible));
179 int find_tree_lb PROTO((tm_prob *tm));
180 
181 /*--------------- Function related to merging descriptions ------------------*/
182 
183 void merge_descriptions PROTO((node_desc *old_node, node_desc *new_node));
184 void merge_base_stat PROTO((double_array_desc *dad,
185  double_array_desc *moddad));
186 void merge_extra_array_and_stat PROTO((array_desc *ad, double_array_desc *dad,
187  array_desc *modad,
188  double_array_desc *moddad));
189 void merge_double_array_descs PROTO((double_array_desc *dad,
190  double_array_desc *newdad));
191 void merge_arrays PROTO((array_desc *array, array_desc *adesc));
192 void modify_list PROTO((array_desc *origad, array_desc *modad));
193 void modify_list_and_stat PROTO((array_desc *origad, int *origstat,
194  array_desc *modad,
195  double_array_desc *moddad));
196 
197 /*--------------- Functions related to two-phase algorithm ------------------*/
198 
199 int tasks_before_phase_two PROTO((tm_prob *tm));
200 int trim_subtree PROTO((tm_prob *tm, bc_node *n));
201 int mark_subtree PROTO((tm_prob *tm, bc_node *n));
202 void propagate_nf_status PROTO((bc_node *n, int nf_status));
203 
204 /*------------------ Functions related to logging ---------------------------*/
205 
206 void write_log_files PROTO((tm_prob *tm));
207 int write_pruned_nodes PROTO((tm_prob *tm, bc_node *node));
208 int write_node PROTO((bc_node *node, char *file, FILE *f, char append));
209 int write_subtree PROTO((bc_node *node, char *file, FILE* f, char append,
210  int logging));
211 int write_tm_cut_list PROTO((tm_prob *tm, char *file, char append));
212 int write_tm_info PROTO((tm_prob *tm, char *file, FILE* f, char append));
213 int write_base PROTO((base_desc *base, char *file, FILE* f, char append));
214 int read_node PROTO((tm_prob *tm, bc_node *node, FILE *f, int **children));
215 int read_subtree PROTO((tm_prob *tm, bc_node *node, FILE *f));
216 int read_tm_cut_list PROTO((tm_prob *tm, char * file));
217 int read_tm_info PROTO((tm_prob *tm, FILE *f));
218 int read_base PROTO((base_desc *base, FILE *f));
219 
220 /*-------------- Functions related to freeing and closing -------------------*/
221 
222 void free_tm PROTO((tm_prob *tm));
223 void free_subtree PROTO((bc_node *n));
224 void free_tree_node PROTO((bc_node *n));
225 void free_basis PROTO((basis_desc *basis));
226 int tm_close PROTO((tm_prob *tm, int termcode));
227 
228 /*===========================================================================*/
229 /*============== TM communication functions (tm_proccomm.c) =================*/
230 /*===========================================================================*/
231 
232 process_set start_processes PROTO((tm_prob *tm,
233  int procnum, char *procname, int procdebug,
234  int machnum, char **mach));
235 void stop_processes PROTO((process_set *pset));
236 char processes_alive PROTO((tm_prob *tm));
237 void send_active_node PROTO((tm_prob *tm, bc_node *node, int colgen_strat,
238  int thread_num));
239 void receive_node_desc PROTO((tm_prob *tm, bc_node *n));
240 void process_branching_info PROTO((tm_prob *tm, bc_node *node));
241 char process_messages PROTO((tm_prob *tm, int r_bufid));
242 void process_ub_message PROTO((tm_prob *tm));
243 void unpack_cut_set PROTO((tm_prob *tm, int sender, int cutnum,
244  row_data *rows));
245 int receive_lp_timing PROTO((tm_prob *tm));
246 
247 void sym_catch_c PROTO((int num));
248 int merge_bound_changes PROTO((bounds_change_desc **bnd_change_ptr,
249  bounds_change_desc *p_bnd_change));
250 int tighten_root_bounds PROTO((tm_prob *p));
251 #endif
char obj_sense
Definition: sym_tm.h:67
double * var_rank
Definition: sym_tm.h:133
int nextphase_cand_size
Definition: sym_tm.h:107
tm_params par
Definition: sym_tm.h:57
#define PROTO(x)
Definition: sym_proto.h:27
double obj_offset
Definition: sym_tm.h:66
char has_ub_estimate
Definition: sym_tm.h:60
int c_size
Definition: sym_tm.h:45
int samephase_cand_size
Definition: sym_tm.h:103
int * br_rel_up
Definition: sym_tm.h:125
int * br_rel_down_min_level
Definition: sym_tm.h:129
int * nodes_per_cp
Definition: sym_tm.h:86
base_desc base
Definition: sym_lp.h:80
int * active_nodes_per_cp
Definition: sym_tm.h:88
Definition: sym_tm.h:56
Definition: sym_cg.h:27
process_set cp
Definition: sym_tm.h:73
problem_stat stat
Definition: sym_tm.h:114
struct TM_TEMP tm_temp
int * bpath_size
Definition: sym_tm.h:142
double * d
Definition: sym_tm.h:46
Definition: sym_tm.h:41
int termcode
Definition: sym_tm.h:69
cut_data ** cuts
Definition: sym_tm.h:112
int * termcodes
Definition: sym_tm.h:70
tm_temp tmp
Definition: sym_tm.h:149
process_set lp
Definition: sym_tm.h:71
int * free_ind
Definition: sym_tm.h:36
bc_node * rootnode
Definition: sym_tm.h:90
double * root_lp
Definition: sym_tm.h:135
int cut_num
Definition: sym_tm.h:110
double * pcost_down
Definition: sym_tm.h:122
int procnum
Definition: sym_tm.h:33
int has_ub
Definition: sym_tm.h:59
int master
Definition: sym_tm.h:58
int * i
Definition: sym_tm.h:42
bc_node ** active_nodes
Definition: sym_tm.h:98
rc_desc * reduced_costs
Definition: sym_tm.h:119
Definition: sym_lp.h:63
int free_num
Definition: sym_tm.h:35
int allocated_cut_num
Definition: sym_tm.h:111
double lb
Definition: sym_tm.h:63
int * br_inf_up
Definition: sym_tm.h:127
int * br_frac_cnt
Definition: sym_tm.h:131
char * c
Definition: sym_tm.h:44
int * rpath_size
Definition: sym_tm.h:140
process_set cg
Definition: sym_tm.h:72
double * pcost_up
Definition: sym_tm.h:123
int * br_rel_cand_list
Definition: sym_tm.h:128
bc_node *** rpath
Definition: sym_tm.h:139
int bvarnum
Definition: sym_tm.h:92
int * br_rel_up_min_level
Definition: sym_tm.h:130
bc_node ** samephase_cand
Definition: sym_tm.h:102
branch_desc ** bpath
Definition: sym_tm.h:141
struct PROCESS_SET process_set
double ub
Definition: sym_tm.h:62
int * var_rank_num
Definition: sym_tm.h:134
lp_sol best_sol
Definition: sym_tm.h:65
int samephase_candnum
Definition: sym_tm.h:101
int * br_inf_down
Definition: sym_tm.h:126
int bcutnum
Definition: sym_tm.h:93
int i_size
Definition: sym_tm.h:43
bc_node ** nextphase_cand
Definition: sym_tm.h:106
int d_size
Definition: sym_tm.h:47
struct TM_PROB tm_prob
int phase
Definition: sym_tm.h:95
double start_time
Definition: sym_tm.h:61
int * br_rel_down
Definition: sym_tm.h:124
double ub_estimate
Definition: sym_tm.h:68
node_times comp_times
Definition: sym_tm.h:116
int nextphase_candnum
Definition: sym_tm.h:105
int active_node_num
Definition: sym_tm.h:97
int * procs
Definition: sym_tm.h:34
int bc_index
Definition: sym_lp.h:109
lp_stat_desc lp_stat
Definition: sym_tm.h:118
double printed_lb
Definition: sym_tm.h:64
sp_desc * sp
Definition: sym_tm.h:151