Dip  0.92.4
sym_lp_solver.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 _LPSOLVER_H
16 #define _LPSOLVER_H
17 
18 #include "sym_proto.h"
19 #include "sym_types.h"
20 #include "sym_lp_params.h"
21 
22 #define LP_MAX_ITER 9999999
23 
24 #ifdef __CPLEX__
25 
26 /*****************************************************************************/
27 /******* here are the definitions for CPLEX *******/
28 /*****************************************************************************/
29 
30 #include <cplex.h>
31 
32 void CPX_check_error PROTO((const char *erring_func));
33 
34 #elif defined(__OSL__)
35 
36 /*****************************************************************************/
37 /******* here are the definitions for OSL *******/
38 /*****************************************************************************/
39 
40 #include <ekk_c_api.h>
41 
42 void OSL_check_error PROTO((const char *erring_func));
43 
44 #elif defined(__OSI_CPLEX__) || defined(__OSI_OSL__) || defined(__OSI_CLP__) \
45 || defined(__OSI_XPRESS__) || defined(__OSI_SOPLEX__) || defined(__OSI_VOL__) \
46 || defined(__OSI_DYLP__) || defined (__OSI_GLPK__)
47 
48 /*****************************************************************************/
49 /******* here are the definitions for OSI *******/
50 /*****************************************************************************/
51 
52 #include "OsiSolverInterface.hpp"
53 #include "CoinHelperFunctions.hpp"
54 #include "CoinPackedVector.hpp"
55 #include "CoinMpsIO.hpp"
56 #include "CoinLpIO.hpp"
57 
58 #ifdef USE_CGL_CUTS
59 #include "OsiCuts.hpp"
60 #include "CglCutGenerator.hpp"
61 #include "CglLiftAndProject.hpp"
62 #include "CglSimpleRounding.hpp"
64 #include "CglClique.hpp"
65 #include "CglGomory.hpp"
66 #include "CglOddHole.hpp"
67 #include "CglKnapsackCover.hpp"
68 #include "CglProbing.hpp"
69 #include "CglFlowCover.hpp"
70 #include "CglTwomir.hpp"
71 #include "CglLandP.hpp"
72 #include "CglRedSplit.hpp"
73 #endif
74 
75 #ifdef __OSI_CPLEX__
76 #include "cplex.h"
78 typedef OsiCpxSolverInterface OsiXSolverInterface;
79 #endif
80 
81 #ifdef __OSI_OSL__
82 #include "OsiOslSolverInterface.hpp"
83 typedef OsiOslSolverInterface OsiXSolverInterface;
84 #endif
85 
86 #ifdef __OSI_CLP__
88 typedef OsiClpSolverInterface OsiXSolverInterface;
89 #endif
90 
91 #ifdef __OSI_XPRESS__
93 typedef OsiXprSolverInterface OsiXSolverInterface;
94 #endif
95 
96 #ifdef __OSI_SOPLEX__
98 typedef OsiSpxSolverInterface OsiXSolverInterface;
99 #endif
100 
101 #ifdef __OSI_VOL__
102 #include "OsiVolSolverInterface.hpp"
103 typedef OsiVolSolverInterface OsiXSolverInterface;
104 #endif
105 
106 #ifdef __OSI_DYLP__
107 #include "OsiDylpSolverInterface.hpp"
108 typedef OsiDylpSolverInterface OsiXSolverInterface;
109 #endif
110 
111 #ifdef __OSI_GLPK__
113 typedef OsiGlpkSolverInterface OsiXSolverInterface;
114 #endif
115 
116 #else
117 
118 #error ###################################
119 #error # Undefined or unknown LP solver.
120 #error # Please edit SYMPHONY/Makefile
121 #error # and define LP_SOLVER properly.
122 #error ###################################
123 
124 #endif
125 
126 /*****************************************************************************/
127 /******* end LP solver definitions *******/
128 /*****************************************************************************/
129 
130 #ifdef USE_GLPMPL
131 extern "C"
132 {
133  #include "glpk.h"
134 }
135 #endif
136 
137 /* Temporary storage */
138 
139 typedef struct TEMPORARY{
140  char *c; /* max(2m,n) */
141  int *i1; /* 3m+2n */
142  int *i2; /* m */
143  double *d; /* max(2m,2n) */
144  void **p1; /* m */
145  void **p2; /* m */
146 
147  char *cv; /* variable */
148  int cv_size;
149  int *iv; /* variable (>= */
150  int iv_size;
151  double *dv; /* variable */
152  int dv_size;
153 }temporary;
154 
155 /* The LP solver data */
156 
157 typedef struct LPDATA{
158  /* First, the problem pointers */
159 #ifdef __CPLEX__
160  CPXENVptr cpxenv;
161  CPXLPptr lp;
162 #endif
163 #ifdef __OSL__
164  EKKContext *env;
165  EKKModel *lp;
166 #endif
167 #if defined(__OSI_CPLEX__) || defined(__OSI_OSL__) || defined(__OSI_CLP__) \
168 || defined(__OSI_XPRESS__) || defined(__OSI_SOPLEX__) || defined(__OSI_VOL__) \
169 || defined(__OSI_DYLP__) || defined (__OSI_GLPK__)
170  OsiXSolverInterface * si;
171 #endif
172  double lpetol;
175  double objval;
176  int termcode;
178  int n; /* number of columns without slacks */
179  int maxn;
180  int m; /* number of rows */
181  int maxm;
182  int nz; /* number of nonzeros */
183  int maxnz; /* space is allocated for this many nonzeros */
184  double *random_hash;
185  double *heur_solution; /* space for heur solution */
186  double *col_solution; /* space for old ip solution - used for heuristics*/
187 
188  double *hashes; /* per iter */
192 
193  char ordering; /* COLIND_AND_USERIND_ORDERED, COLIND_ORDERED or
194  USERIND_ORDERED */
195  var_desc **vars; /* maxn */ /* BB */
196 
198  int *not_fixed;
200 
201  char *status; /* maxn */ /* BB */
202  double *x; /* maxn */ /* BB */
203  double *dj; /* maxn */ /* BB */
204  double *dualsol; /* maxm */ /* BB */
205  double *slacks; /* maxm */
206  double *ub;
207  double *lb;
208 
209  row_data *rows; /* maxm */
210 
211  temporary tmp; /* to be used in some heurs and elsewhere */
212 
213  int tmp1_size;
214  int tmp2_size;
215  temporary tmp1; /* to be used in recursive heurs */
216  temporary tmp2; /* to be used in branching routines */
217 
218 #ifdef PSEUDO_COSTS
219  double *pseudo_costs_one;
220  double *pseudo_costs_zero;
221 #endif
222  int lp_count;
224 
226 
227 }LPdata;
228 
229 /*****************************************************************************/
230 /******* common definitions *******/
231 /*****************************************************************************/
232 
233 double dot_product PROTO((double *val, int *ind, int collen, double *col));
234 void free_lp_arrays PROTO((LPdata *lp_data));
235 void free_mip_desc PROTO((MIPdesc *mip));
236 void size_lp_arrays PROTO((LPdata *lp_data, char do_realloc, char set_max,
237  int row_num, int col_num, int nzcnt));
238 void open_lp_solver PROTO((LPdata *lp_data));
239 void close_lp_solver PROTO((LPdata *lp_data));
240 void load_lp_prob PROTO((LPdata *lp_data, int scaling, int fastmip));
241 int reset_lp_prob PROTO ((LPdata *lp_data, int scaling, int fastmip));
242 int save_lp PROTO((LPdata *lp_data));
243 void unload_lp_prob PROTO((LPdata *lp_data));
244 void load_basis PROTO((LPdata *lp_data, int *cstat, int *rstat));
245 void refactorize PROTO((LPdata *lp_data));
246 void add_rows PROTO((LPdata *lp_data, int rcnt, int nzcnt, double *rhs,
247  char *sense, int *rmatbeg, int *rmatind,double *rmatval));
248 void add_cols PROTO((LPdata *lp_data, int ccnt, int nzcnt, double *obj,
249  int *cmatbeg, int *cmatind, double *cmatval,
250  double *lb, double *ub, char *where_to_move));
251 void change_row PROTO((LPdata *lp_data, int row_ind,
252  char sense, double rhs, double range));
253 void change_col PROTO((LPdata *lp_data, int col_ind,
254  char sense, double lb, double ub));
255 int initial_lp_solve PROTO((LPdata *lp_data, int *iterd));
256 int dual_simplex PROTO((LPdata *lp_data, int *iterd));
257 int solve_hotstart PROTO((LPdata *lp_data, int *iterd));
258 int mark_hotstart PROTO((LPdata *lp_data));
259 int unmark_hotstart PROTO((LPdata *lp_data));
260 void btran PROTO((LPdata *lp_data, double *col));
261 void get_binvcol PROTO((LPdata *lp_data, int j, double *col));
262 void get_binvrow PROTO((LPdata *lp_data, int i, double *row));
263 void get_basis PROTO((LPdata *lp_data, int *cstat, int *rstat));
264 void set_obj_upper_lim PROTO((LPdata *lp_data, double lim));
265 void set_timelim PROTO((LPdata *lp_data, double timelim));
266 void set_itlim PROTO((LPdata *lp_data, int itlim));
267 void set_itlim_hotstart PROTO((LPdata *lp_data, int itlim));
268 void get_column PROTO((LPdata *lp_data, int j,
269  double *colval, int *colind, int *collen, double *cj));
270 void get_row PROTO((LPdata *lp_data, int i,
271  double *rowval, int *rowind, int *rowlen,
272  double *rowub, double *rowlb));
273 int get_proof_of_infeas PROTO((LPdata *lp_data, int *infind));
274 void get_x PROTO((LPdata *lp_data));
275 void get_dj_pi PROTO((LPdata *lp_data));
276 void get_slacks PROTO((LPdata *lp_data));
277 void change_range PROTO((LPdata *lp_data, int rowind, double value));
278 void change_rhs PROTO((LPdata *lp_data,
279  int rownum, int *rhsind, double *rhsval));
280 void change_sense PROTO((LPdata *lp_data, int cnt, int *index, char *sense));
281 void change_bounds PROTO((LPdata *lp_data,
282  int cnt, int *index, char *lu, double *bd));
283 void change_lbub PROTO((LPdata *lp_data, int j, double lb, double ub));
284 void change_ub PROTO((LPdata *lp_data, int j, double ub));
285 void change_lb PROTO((LPdata *lp_data, int j, double lb));
286 void get_ub PROTO((LPdata *lp_data, int j, double *ub));
287 void get_lb PROTO((LPdata *lp_data, int j, double *lb));
288 void get_bounds PROTO((LPdata *lp_data));
289 void get_objcoef PROTO((LPdata *lp_data, int j, double *objcoef));
290 void get_objcoeffs(LPdata *lp_data);
291 void change_objcoeff(LPdata *lp_data, const int* indexFirst,
292  const int* indexLast, double *coeffs);
293 void get_rhs_rng_sense(LPdata *lp_data);
294 int copy_lp_data(LPdata *lp_data, LPdata *new_data);
295 void delete_rows PROTO((LPdata *lp_data, int deletable, int *free_rows));
296 void delete_rows_with_ind PROTO((LPdata *lp_data, int deletable, int *rowind));
297 int delete_cols PROTO((LPdata *lp_data, int delnum, int *delstat));
298 void release_var PROTO((LPdata *lp_data, int j, int where_to_move));
299 void free_row_set PROTO((LPdata *lp_data, int length, int *index));
300 void constrain_row_set PROTO((LPdata *lp_data, int length, int *index));
301 int read_mps PROTO((MIPdesc *mip, char *infile, char *probname, int verbosity));
302 int read_lp PROTO((MIPdesc *mip, char *infile, char *probname, int verbosity));
303 void write_mps PROTO((LPdata *lp_data, char *fname));
304 void write_lp PROTO((LPdata *lp_data, char *fname));
305 void write_mip_desc_mps PROTO((MIPdesc *mip, char *fname));
306 void write_mip_desc_lp PROTO((MIPdesc *mip, char *fname));
307 void write_sav PROTO((LPdata *lp_data, char *fname));
308 #ifdef USE_CGL_CUTS
309 void generate_cgl_cuts(LPdata *lp_data, int *num_cuts, cut_data ***cuts,
310  char send_to_pool, int bc_index, int bc_level,
311  int node_iter_limit, int max_cuts_before_resolve,
312  double ub, int *bnd_changes,
313  lp_stat_desc *lp_stat, node_times *comp_times,
314  int verbosity);
315 int check_cuts(OsiCuts &cutlist, LPdata *lp_data, int bc_level, int
316  *num_cuts, cut_data ***cuts, char send_to_pool, int *bnd_changes,
317  lp_stat_desc *lp_stat, node_times *compe_times, int verbosity);
318 int should_generate_this_cgl_cut(int cut_num, int max_cuts_before_resolve,
319  int generation_flag, int freq, int bc_level, int bc_index,
320  int cuts_in_root, int *should_generate);
321 /*
322 void generate_cgl_cuts PROTO((LPdata * lp_data, int *num_cuts,
323  cut_data ***cuts, char send_to_pool,
324  int is_rootnode, lp_stat_desc *lp_stat,
325  node_times *comp_times, int verbosity));
326 */
327 #endif
328 #ifdef USE_GLPMPL
329 int read_gmpl PROTO((MIPdesc *mip, char *modelfile, char *datafile,
330  char *probname));
331 #endif
332 #endif
temporary tmp1
double * ub
#define PROTO(x)
Definition: sym_proto.h:27
int tmp2_size
char * status
int copy_lp_data(LPdata *lp_data, LPdata *new_data)
double lpetol
double * slacks
row_data * rows
CPLEX Solver Interface.
SoPlex Solver Interface Instantiation of OsiSpxSolverInterface for SoPlex.
void get_objcoeffs(LPdata *lp_data)
double * hashes
char lp_is_modified
void ** p1
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
MIPdesc * mip
int tmp1_size
char ordering
cgl_params cgl
int hashes_num
int lp_count
double * d
void ** p2
double * col_solution
temporary tmp
double * dv
int nf_status
double * random_hash
int * not_fixed
Clp Solver Interface.
unsigned int verbosity
Verbosity level of unit tests.
int not_fixed_num
int accepted_num
char col_set_changed
double * dj
double objval
XPRESS-MP Solver Interface.
int * accepted_ind
temporary tmp2
double * heur_solution
struct TEMPORARY temporary
struct cpxenv * CPXENVptr
struct LPDATA LPdata
double * x
struct cpxlp * CPXLPptr
void change_objcoeff(LPdata *lp_data, const int *indexFirst, const int *indexLast, double *coeffs)
double * dualsol
var_desc ** vars
int * frac_var_cnt
void get_rhs_rng_sense(LPdata *lp_data)
int termcode
double * lb