]> git.pld-linux.org Git - packages/CoinOsi.git/blob - Osi-glpk.patch
- ldconfig for solver libraries
[packages/CoinOsi.git] / Osi-glpk.patch
1 --- Osi-0.106.10/Osi/src/OsiGlpk/OsiGlpkSolverInterface.cpp.orig        2013-04-06 14:50:19.000000000 +0200
2 +++ Osi-0.106.10/Osi/src/OsiGlpk/OsiGlpkSolverInterface.cpp     2014-12-04 17:58:31.036909826 +0100
3 @@ -21,7 +21,7 @@
4  //    In (much) earlier versions of GLPK, if an LPX_MIP problem was
5  // changed back into a LPX_LP problem, then the MIP data was lost,
6  // including which columns are integer.  However, LPX_MIP problems
7 -// still had access to LP information (like lpx_get_status).
8 +// still had access to LP information (like glp_get_status).
9  //
10  //    It appears that this behavior is no longer true in version 4.7.
11  // Therefore it may be worthwhile to adjust the interface to change
12 @@ -166,26 +166,26 @@ void OGSI::initialSolve()
13  /*
14    Solve the lp.
15  */
16 -  int err = lpx_simplex(model) ;
17 +  int err = glp_simplex(model, &simplexParams_) ;
18  
19    // for Glpk, a solve fails if the initial basis is invalid or singular
20    // thus, we construct a (advanced) basis first and try again
21 -#ifdef LPX_E_BADB
22 -  if (err == LPX_E_BADB) {
23 -    lpx_adv_basis(model);
24 -    err = lpx_simplex(model) ;
25 +#ifdef GLP_EBADB
26 +  if (err == GLP_EBADB) {
27 +    glp_adv_basis(model, 0);
28 +    err = glp_simplex(model, &simplexParams_) ;
29    } else
30  #endif
31 -  if (err == LPX_E_SING || err == LPX_E_FAULT) {
32 -    lpx_adv_basis(model);
33 -    err = lpx_simplex(model) ;
34 +  if (err == GLP_ESING || err == GLP_EFAIL) {
35 +    glp_adv_basis(model, 0);
36 +    err = glp_simplex(model, &simplexParams_) ;
37    }
38  
39 -  iter_used_ = lpx_get_int_parm(model, LPX_K_ITCNT) ;
40 +  iter_used_ = glp_get_it_cnt(model) ;
41  /*
42    Sort out the various state indications.
43  
44 -  When the presolver is turned on, lpx_simplex() will not be able to tell
45 +  When the presolver is turned on, glp_simplex() will not be able to tell
46    whether the objective function has hit it's upper or lower limit, and does
47    not return OBJLL or OBJUL. The code for these cases should be beefed up to
48    check the objective against the limit.
49 @@ -204,39 +204,39 @@ void OGSI::initialSolve()
50    isObjUpperLimitReached_ = false ;
51  
52    switch (err)
53 -  { case LPX_E_OK:
54 +  { case 0:
55      { break ; }
56 -    case LPX_E_ITLIM:
57 +    case GLP_EITLIM:
58      { isIterationLimitReached_ = true ;
59        break ; }
60 -    case LPX_E_OBJLL:
61 +    case GLP_EOBJLL:
62      { isObjLowerLimitReached_ = true ;
63        break ; }
64 -    case LPX_E_OBJUL:
65 +    case GLP_EOBJUL:
66      { isObjUpperLimitReached_ = true ;
67        break ; }
68 -    case LPX_E_TMLIM:
69 +    case GLP_ETMLIM:
70      { isTimeLimitReached_ = true ;
71      } // no break here, so we still report abandoned
72 -    case LPX_E_FAULT:
73 -    case LPX_E_SING:
74 -#ifdef LPX_E_BADB
75 -    case LPX_E_BADB:
76 +    case GLP_EFAIL:
77 +    case GLP_ESING:
78 +#ifdef GLP_EBADB
79 +    case GLP_EBADB:
80  #endif
81      { isAbandoned_ = true ;
82        break ; }
83 -    case LPX_E_NOPFS:
84 +    case GLP_ENOPFS:
85      { isPrimInfeasible_ = true ;
86        break ; }
87 -    case LPX_E_NODFS:
88 +    case GLP_ENODFS:
89      { isDualInfeasible_ = true ;
90        break ; }
91      default:
92      { assert(false) ; } }
93      
94 -  switch (lpx_get_status(model))
95 -  { case LPX_OPT:
96 -       case LPX_FEAS:
97 +  switch (glp_get_status(model))
98 +  { case GLP_OPT:
99 +       case GLP_FEAS:
100         { isFeasible_ = true ;
101                 break ; }
102         default:
103 @@ -261,23 +261,23 @@ void OGSI::resolve()
104    LPX *model = getMutableModelPtr() ;
105    freeCachedData(OGSI::FREECACHED_RESULTS) ;
106  
107 -  // lpx_simplex will use the current basis if possible
108 -  int err = lpx_simplex(model) ;
109 +  // glp_simplex will use the current basis if possible
110 +  int err = glp_simplex(model, &simplexParams_) ;
111  
112    // for Glpk, a solve fails if the initial basis is invalid or singular
113    // thus, we construct a (advanced) basis first and try again
114 -#ifdef LPX_E_BADB
115 -  if (err == LPX_E_BADB) {
116 -    lpx_adv_basis(model);
117 -    err = lpx_simplex(model) ;
118 +#ifdef GLP_EBADB
119 +  if (err == GLP_EBADB) {
120 +    glp_adv_basis(model, 0);
121 +    err = glp_simplex(model, &simplexParams_) ;
122    } else
123  #endif
124 -  if (err == LPX_E_SING || err == LPX_E_FAULT) {
125 -    lpx_adv_basis(model);
126 -    err = lpx_simplex(model) ;
127 +  if (err == GLP_ESING || err == GLP_EFAIL) {
128 +    glp_adv_basis(model, 0);
129 +    err = glp_simplex(model, &simplexParams_) ;
130    }
131    
132 -  iter_used_ = lpx_get_int_parm(model,LPX_K_ITCNT) ;
133 +  iter_used_ = glp_get_it_cnt(model) ;
134  
135    isIterationLimitReached_ = false ;
136    isTimeLimitReached_ = false ;
137 @@ -289,39 +289,39 @@ void OGSI::resolve()
138    isFeasible_ = false ;
139  
140    switch (err)
141 -  { case LPX_E_OK:
142 +  { case 0:
143      { break ; }
144 -    case LPX_E_ITLIM:
145 +    case GLP_EITLIM:
146      { isIterationLimitReached_ = true ;
147        break ; }
148 -    case LPX_E_OBJLL:
149 +    case GLP_EOBJLL:
150      { isObjLowerLimitReached_ = true ;
151        break ; }
152 -    case LPX_E_OBJUL:
153 +    case GLP_EOBJUL:
154      { isObjUpperLimitReached_ = true ;
155        break ; }
156 -    case LPX_E_TMLIM:
157 +    case GLP_ETMLIM:
158      { isTimeLimitReached_ = true ;
159      } // no break here, so we still report abandoned
160 -    case LPX_E_FAULT:
161 -    case LPX_E_SING:
162 -#ifdef LPX_E_BADB
163 -    case LPX_E_BADB:
164 +    case GLP_EFAIL:
165 +    case GLP_ESING:
166 +#ifdef GLP_EBADB
167 +    case GLP_EBADB:
168  #endif
169      { isAbandoned_ = true ;
170        break ; }
171 -    case LPX_E_NOPFS:
172 +    case GLP_ENOPFS:
173      { isPrimInfeasible_ = true ;
174        break ; }
175 -    case LPX_E_NODFS:
176 +    case GLP_ENODFS:
177      { isDualInfeasible_ = true ;
178        break ; }
179      default:
180      { assert(false) ; } }
181  
182 -  switch (lpx_get_status(model))
183 -  { case LPX_OPT:
184 -       case LPX_FEAS:
185 +  switch (glp_get_status(model))
186 +  { case GLP_OPT:
187 +       case GLP_FEAS:
188         { isFeasible_ = true ;
189                 break ; }
190         default:
191 @@ -337,7 +337,7 @@ void OGSI::resolve()
192  
193  /*
194    Call glpk's built-in MIP solver. Any halfway recent version (from glpk 4.4,
195 -  at least) will have lpx_intopt, a branch-and-cut solver. The presence of cut
196 +  at least) will have glp_intopt, a branch-and-cut solver. The presence of cut
197    generators is more recent.
198  */
199  void OGSI::branchAndBound ()
200 @@ -351,52 +351,46 @@ void OGSI::branchAndBound ()
201    Assuming we have integer variables in the model, call the best MIP solver
202    we can manage.
203  
204 -  lpx_intopt does not require an optimal LP solution as a starting point, so
205 +  glp_intopt does not require an optimal LP solution as a starting point, so
206    we can call it directly.
207  
208    lpx_integer needs an initial optimal solution to the relaxation.
209  */
210 -  if (lpx_get_num_int(model))
211 -  { int err = LPX_E_FAULT ;
212 +  if (glp_get_num_int(model))
213 +  { int err = GLP_EFAIL ;
214  
215 -#   ifdef GLPK_HAS_INTOPT
216 -    err = lpx_intopt(model) ;
217 -#   else
218 -    if (lpx_get_status(model) != LPX_OPT)
219 -    { initialSolve() ; }
220 -    err = lpx_integer(model) ;
221 -#   endif
222 +    err = glp_intopt(model, &intoptParams_) ;
223  /*
224    We have a result. What is it? Start with a positive attitude and revise as
225 -  needed. The various LPX_E_* and LPX_I_* defines are stable back as far as
226 -  glpk-4.4.
227 +  needed. The various GLP_E* and GLP_* defines are stable back as far as
228 +  glpk-4.5x.
229  
230 -  When we get LPX_E_OK (MIP terminated normally), we need to look more
231 -  closely.  LPX_I_OPT indicates a proven optimal integer solution.
232 -  LPX_I_NOFEAS indicates that there is no integer feasible solution.
233 -  LPX_I_UNDEF says the MIP solution is undefined. LPX_I_FEAS says that in
234 +  When we get 0 (MIP terminated normally), we need to look more
235 +  closely.  GLP_OPT indicates a proven optimal integer solution.
236 +  GLP_NOFEAS indicates that there is no integer feasible solution.
237 +  GLP_UNDEF says the MIP solution is undefined. GLP_FEAS says that in
238    integer feasible solution was found but not proven optimal (termination of
239    search due to some limit is the common cause). It's not clear what to do
240 -  with LPX_I_UNDEF; currently, it is not really reflected in
241 -  termination status. LPX_I_FEAS is reflected by the OsiGlpk specific method
242 +  with GLP_UNDEF; currently, it is not really reflected in
243 +  termination status. GLP_FEAS is reflected by the OsiGlpk specific method
244    isFeasible().
245  
246 -  Various other codes are returned by lpx_intopt (lpx_integer returns a
247 -  subset of these).  LPX_E_NOPFS (LPX_E_NODFS) indicate no primal (dual)
248 +  Various other codes are returned by glp_intopt (lpx_integer returns a
249 +  subset of these).  GLP_ENOPFS (GLP_ENODFS) indicate no primal (dual)
250    feasible solution; detected at the root, either by presolve or when
251 -  attempting the root relaxation. LPX_E_ITLIM (LPX_E_TMLIM) indicate
252 +  attempting the root relaxation. GLP_EITLIM (GLP_ETMLIM) indicate
253    iteration (time) limit reached. Osi doesn't provide for time limit, so lump
254    it in with iteration limit (an arguable choice, but seems better than the
255    alternatives) and have extra method isTimeLimitReached().
256 -  LPX_E_SING (lp solver failed due to singular basis) is
257 -  legimately characterised as abandoned.  LPX_E_FAULT indicates a structural
258 +  GLP_ESING (lp solver failed due to singular basis) is
259 +  legimately characterised as abandoned.  GLP_EFAIL indicates a structural
260    problem (problem not of class MIP, or an integer variable has a non-integer
261    bound), which really translates into internal confusion in OsiGlpk.
262  
263    Previous comments expressed uncertainty about the iteration count. This
264    should be checked at some point. -- lh, 070709 --
265  */
266 -    iter_used_ = lpx_get_int_parm(model,LPX_K_ITCNT) ;
267 +    iter_used_ = glp_get_it_cnt(model) ;
268      isIterationLimitReached_ = false ;
269                 isTimeLimitReached_ = false ;
270      isAbandoned_ = false ;
271 @@ -407,45 +401,45 @@ void OGSI::branchAndBound ()
272      isObjUpperLimitReached_ = false ;
273  
274      switch (err)
275 -    { case LPX_E_OK:
276 -#ifdef LPX_E_MIPGAP
277 -    case LPX_E_MIPGAP:
278 +    { case 0:
279 +#ifdef GLP_EMIPGAP
280 +    case GLP_EMIPGAP:
281  #endif
282        { 
283         break ; }
284 -      case LPX_E_NOPFS:
285 +      case GLP_ENOPFS:
286        { isPrimInfeasible_ = true ;
287         break ; }
288 -      case LPX_E_NODFS:
289 +      case GLP_ENODFS:
290        { isDualInfeasible_ = true ;
291         break ; }
292 -      case LPX_E_TMLIM:
293 +      case GLP_ETMLIM:
294        { isTimeLimitReached_ = true ; } // no break
295 -      case LPX_E_ITLIM:
296 +      case GLP_EITLIM:
297        { isIterationLimitReached_ = true ;
298         break ; }
299 -      case LPX_E_SING:
300 +      case GLP_ESING:
301        { isAbandoned_ = true ;
302         break ; }
303 -      case LPX_E_FAULT:
304 +      case GLP_EFAIL:
305        { assert(false) ;
306         break ; }
307        default:
308        { assert(false) ;
309         break ; } }
310         
311 -       //check this also if err!=LPX_E_OPT, so we know about feasibility in case time/resource limit is reached  
312 -       int mip_status = lpx_mip_status(model) ;
313 +       //check this also if err!=GLP_OPT, so we know about feasibility in case time/resource limit is reached  
314 +       int mip_status = glp_mip_status(model) ;
315         switch (mip_status)
316 -       { case LPX_I_OPT:
317 +       { case GLP_OPT:
318           { isFeasible_ = true ;
319                 break ; }
320 -         case LPX_I_NOFEAS:
321 +         case GLP_NOFEAS:
322           { isPrimInfeasible_ = true ;
323             break ; }
324 -         case LPX_I_UNDEF:
325 +         case GLP_UNDEF:
326           { break ; }
327 -         case LPX_I_FEAS:
328 +         case GLP_FEAS:
329           { isFeasible_ = true ;
330                 break ; }
331           default:
332 @@ -458,7 +452,7 @@ void OGSI::branchAndBound ()
333  /*
334    Not a MIP (no integer variables). Call the LP solver. Since we can call
335    branchAndBound with no initial LP solution, initialSolve is appropriate here.
336 -  (But for glpk, it actually makes no difference --- lpx_simplex makes the
337 +  (But for glpk, it actually makes no difference --- glp_simplex makes the
338    decision on how to proceed.)
339  */
340    else
341 @@ -490,7 +484,7 @@ bool OGSI::setIntParam (OsiIntParam key,
342    { case OsiMaxNumIteration:
343      { if (value >= 0)
344        { maxIteration_ = value ;
345 -       lpx_set_int_parm(lp_,LPX_K_ITLIM,value) ;
346 +       simplexParams_.it_lim = value ;
347         retval = true ; }
348        else
349        { retval = false ; }
350 @@ -531,24 +525,24 @@ bool OGSI::setDblParam (OsiDblParam key,
351      // as of 4.7, GLPK only uses this if it does dual simplex
352      { dualObjectiveLimit_ = value ;
353        if (getObjSense() == 1)                          // minimization
354 -      { lpx_set_real_parm(lp_,LPX_K_OBJUL,value) ; }
355 +      { simplexParams_.obj_ul = value ; }
356        else                                             // maximization
357 -      { lpx_set_real_parm(lp_,LPX_K_OBJLL,value) ; }
358 +      { simplexParams_.obj_ll = value ; }
359        retval = true ; 
360        break ; }
361      case OsiPrimalObjectiveLimit:
362      // as of 4.7, GLPK only uses this if it does dual simplex
363      { primalObjectiveLimit_ = value ;
364        if (getObjSense() == 1)
365 -      { lpx_set_real_parm(lp_,LPX_K_OBJLL,value) ; }
366 +      { simplexParams_.obj_ll = value ; }
367        else
368 -      { lpx_set_real_parm(lp_,LPX_K_OBJUL,value) ; }
369 +      { simplexParams_.obj_ul = value ; }
370        retval = true ; 
371        break ; }
372      case OsiDualTolerance:
373      { if (value >= 0 && value <= .001)
374        { dualTolerance_ = value;
375 -       lpx_set_real_parm(lp_,LPX_K_TOLDJ,value) ;
376 +       simplexParams_.tol_dj = value ;
377         retval = true ; }
378        else
379        { retval = false ; }
380 @@ -556,14 +550,14 @@ bool OGSI::setDblParam (OsiDblParam key,
381      case OsiPrimalTolerance:
382      { if (value >= 0 && value <= .001)
383        { primalTolerance_ = value ;
384 -       lpx_set_real_parm(lp_,LPX_K_TOLBND,value) ;
385 +       simplexParams_.tol_bnd = value ;
386         retval = true ; }
387        else
388        { retval = false ; }
389        break ; }
390      case OsiObjOffset:
391      { objOffset_ = value ;
392 -      lpx_set_obj_coef(lp_,0,value) ;
393 +      glp_set_obj_coef(lp_,0,value) ;
394        retval = true ;
395        break ; }
396      case OsiLastDblParam:
397 @@ -583,7 +577,7 @@ bool OGSI::setStrParam (OsiStrParam key,
398      { probName_ = value ;
399        if (probName_.length() == 0)
400          probName_ = "Pb";
401 -      lpx_set_prob_name(lp_,const_cast<char *>(value.c_str())) ;
402 +      glp_set_prob_name(lp_,const_cast<char *>(value.c_str())) ;
403        retval = true ;
404        break ; }
405      case OsiSolverName:
406 @@ -665,18 +659,18 @@ bool OGSI::setHintParam (OsiHintParam ke
407      case OsiDoPresolveInInitial:
408      case OsiDoPresolveInResolve:
409      { if (sense == false)
410 -      { if (strength >= OsiHintTry) lpx_set_int_parm(lp_,LPX_K_PRESOL,0) ; }
411 +      { if (strength >= OsiHintTry) simplexParams_.presolve = intoptParams_.presolve = 0 ; }
412        else
413 -      { lpx_set_int_parm(lp_,LPX_K_PRESOL,1) ; }
414 +      { simplexParams_.presolve = intoptParams_.presolve = 1 ; }
415        retval = true ;
416        break ; }
417      case OsiDoDualInInitial:
418      case OsiDoDualInResolve:
419      { unimp_hint(msgHdl,false,sense,strength,"exclusive use of dual simplex") ;
420        if (sense == false)
421 -      { if (strength >= OsiHintDo) lpx_set_int_parm(lp_,LPX_K_DUAL,0) ; }
422 +      { if (strength >= OsiHintDo) simplexParams_.meth = GLP_PRIMAL ; }
423        else
424 -      { lpx_set_int_parm(lp_,LPX_K_DUAL,1) ; }
425 +      { simplexParams_.meth = GLP_DUALP ; }
426        retval = true ;
427        break ; }
428      case OsiDoCrash:
429 @@ -692,9 +686,10 @@ bool OGSI::setHintParam (OsiHintParam ke
430  */
431      case OsiDoScale:
432      { if (sense == false)
433 -      { if (strength >= OsiHintTry) lpx_set_int_parm(lp_,LPX_K_SCALE,0) ; }
434 +      { if (strength >= OsiHintTry) scaleFlags_ = 0 ; }
435        else
436 -      { lpx_set_int_parm(lp_,LPX_K_SCALE,3) ; }
437 +      { scaleFlags_ = GLP_SF_GM | GLP_SF_EQ ; }
438 +      glp_scale_prob(lp_, scaleFlags_);
439        retval = true ;
440        break ; }
441  /*
442 @@ -704,15 +699,15 @@ bool OGSI::setHintParam (OsiHintParam ke
443      case OsiDoReducePrint:
444      { if (sense == true)
445        { if (strength <= OsiHintTry)
446 -       { lpx_set_int_parm(lp_,LPX_K_MSGLEV,1) ; }
447 +       { simplexParams_.msg_lev = intoptParams_.msg_lev = GLP_MSG_ERR ; }
448         else
449 -       { lpx_set_int_parm(lp_,LPX_K_MSGLEV,0) ; } }
450 +       { simplexParams_.msg_lev = intoptParams_.msg_lev = GLP_MSG_OFF ; } }
451        else
452        { if (strength <= OsiHintTry)
453 -       { lpx_set_int_parm(lp_,LPX_K_MSGLEV,2) ; }
454 +       { simplexParams_.msg_lev = intoptParams_.msg_lev = GLP_MSG_ON ; }
455         else
456 -       { lpx_set_int_parm(lp_,LPX_K_MSGLEV,3) ; } }
457 -      int logLevel = lpx_get_int_parm(lp_,LPX_K_MSGLEV) ;
458 +       { simplexParams_.msg_lev = intoptParams_.msg_lev = GLP_MSG_ALL ; } }
459 +      int logLevel = simplexParams_.msg_lev ;
460        messageHandler()->setLogLevel(logLevel) ;
461        retval = true ;
462        break ; }
463 @@ -787,7 +782,7 @@ OGSI::getDblParam( OsiDblParam key, doub
464                 break;
465  
466      case OsiObjOffset:
467 -                value = lpx_get_obj_coef(getMutableModelPtr(),0);
468 +                value = glp_get_obj_coef(getMutableModelPtr(),0);
469                 retval = true;
470                 break;
471  
472 @@ -805,7 +800,7 @@ OGSI::getStrParam(OsiStrParam key, std::
473    //   bool retval = false;
474    switch (key) {
475    case OsiProbName:
476 -    value = lpx_get_prob_name( getMutableModelPtr() );
477 +    value = glp_get_prob_name( getMutableModelPtr() );
478      break;
479    case OsiSolverName:
480      value = "glpk";
481 @@ -830,13 +825,13 @@ bool OGSI::isProvenOptimal() const
482  
483         if( bbWasLast_ == 0 )
484           {
485 -           int stat = lpx_get_status( model );
486 -           return stat == LPX_OPT;
487 +           int stat = glp_get_status( model );
488 +           return stat == GLP_OPT;
489           }
490         else
491           {
492 -           int stat = lpx_mip_status( model );
493 -           return stat == LPX_I_OPT;
494 +           int stat = glp_mip_status( model );
495 +           return stat == GLP_OPT;
496           }
497  }
498  
499 @@ -848,9 +843,9 @@ bool OGSI::isProvenPrimalInfeasible() co
500                 return true;
501  
502         if( bbWasLast_ == 0 )
503 -               return lpx_get_prim_stat( model ) == LPX_P_NOFEAS;
504 +               return glp_get_prim_stat( model ) == GLP_NOFEAS;
505         else
506 -               return lpx_mip_status( model ) == LPX_I_NOFEAS;
507 +               return glp_mip_status( model ) == GLP_NOFEAS;
508  }
509  
510  bool OGSI::isProvenDualInfeasible() const
511 @@ -861,7 +856,7 @@ bool OGSI::isProvenDualInfeasible() cons
512                 return true;
513  
514         if( bbWasLast_ == 0 )
515 -               return lpx_get_dual_stat( model ) == LPX_D_NOFEAS;
516 +               return glp_get_dual_stat( model ) == GLP_NOFEAS;
517         else
518           // Not sure what to do for MIPs;  does it just mean unbounded?
519           // ??? for now, return false
520 @@ -933,7 +928,7 @@ bool OGSI::isFeasible() const
521  /*
522    Return a warm start object matching the current state of the solver.
523  
524 -  Nonbasic fixed variables (LPX_NS) are translated to CWSB::atLowerBound.
525 +  Nonbasic fixed variables (GLP_NS) are translated to CWSB::atLowerBound.
526  */
527  CoinWarmStart *OGSI::getWarmStart() const
528  
529 @@ -953,19 +948,19 @@ CoinWarmStart *OGSI::getWarmStart() cons
530     and  Glpk's at-upper-bound will be mapped to Osi's at-lower-bound. 
531  */
532    for (int i = 0 ; i < numrows ; i++)
533 -  { int stati = lpx_get_row_stat(lp_,i+1) ;
534 +  { int stati = glp_get_row_stat(lp_,i+1) ;
535      switch (stati)
536 -    { case LPX_BS:
537 +    { case GLP_BS:
538        { ws->setArtifStatus(i,CoinWarmStartBasis::basic) ;
539         break ; }
540 -      case LPX_NS:
541 -      case LPX_NL:
542 +      case GLP_NS:
543 +      case GLP_NL:
544        { ws->setArtifStatus(i,CoinWarmStartBasis::atUpperBound) ;
545         break ; }
546 -      case LPX_NU:
547 +      case GLP_NU:
548        { ws->setArtifStatus(i,CoinWarmStartBasis::atLowerBound) ;
549         break ; }
550 -      case LPX_NF:
551 +      case GLP_NF:
552        { ws->setArtifStatus(i,CoinWarmStartBasis::isFree) ;
553         break ; }
554        default:
555 @@ -975,19 +970,19 @@ CoinWarmStart *OGSI::getWarmStart() cons
556    And repeat for the columns.
557  */
558    for (int j = 0 ; j < numcols ; j++)
559 -  { int statj = lpx_get_col_stat(lp_,j+1) ;
560 +  { int statj = glp_get_col_stat(lp_,j+1) ;
561      switch (statj)
562 -    { case LPX_BS:
563 +    { case GLP_BS:
564        { ws->setStructStatus(j,CoinWarmStartBasis::basic) ;
565         break ; }
566 -      case LPX_NS:
567 -      case LPX_NL:
568 +      case GLP_NS:
569 +      case GLP_NL:
570        { ws->setStructStatus(j,CoinWarmStartBasis::atLowerBound) ;
571         break ; }
572 -      case LPX_NU:
573 +      case GLP_NU:
574        { ws->setStructStatus(j,CoinWarmStartBasis::atUpperBound) ;
575         break ; }
576 -      case LPX_NF:
577 +      case GLP_NF:
578        { ws->setStructStatus(j,CoinWarmStartBasis::isFree) ;
579         break ; }
580        default:
581 @@ -1040,44 +1035,44 @@ bool OGSI::setWarmStart (const CoinWarmS
582  
583      switch (ws->getArtifStatus(i))
584      { case CoinWarmStartBasis::basic:
585 -      { stati = LPX_BS ;
586 +      { stati = GLP_BS ;
587         break ; }
588        case CoinWarmStartBasis::atLowerBound:
589 -      { stati = LPX_NU ;
590 +      { stati = GLP_NU ;
591         break ; }
592        case CoinWarmStartBasis::atUpperBound:
593 -      { stati = LPX_NL ;
594 +      { stati = GLP_NL ;
595         break ; }
596        case CoinWarmStartBasis::isFree:
597 -      { stati = LPX_NF ;
598 +      { stati = GLP_NF ;
599         break ; }
600        default:
601        { assert(false) ;
602         return (false) ; } }            
603  
604 -    lpx_set_row_stat(lp_,i+1,stati) ; }
605 +    glp_set_row_stat(lp_,i+1,stati) ; }
606    
607    for (int j = 0 ; j < numcols ; j++)
608    { int statj ;
609  
610      switch (ws->getStructStatus(j))
611      { case CoinWarmStartBasis::basic:
612 -      { statj = LPX_BS ;
613 +      { statj = GLP_BS ;
614         break ; }
615        case CoinWarmStartBasis::atLowerBound:
616 -      { statj = LPX_NL ;
617 +      { statj = GLP_NL ;
618         break ; }
619        case CoinWarmStartBasis::atUpperBound:
620 -      { statj = LPX_NU ;
621 +      { statj = GLP_NU ;
622         break ; }
623        case CoinWarmStartBasis::isFree:
624 -      { statj = LPX_NF ;
625 +      { statj = GLP_NF ;
626         break ; }
627        default:
628        { assert(false) ;
629         return (false) ; } }
630  
631 -    lpx_set_col_stat(lp_,j+1,statj) ; }
632 +    glp_set_col_stat(lp_,j+1,statj) ; }
633  
634    return (true) ; }
635  
636 @@ -1108,9 +1103,9 @@ void OGSI::markHotStart()
637                 int stat;
638                 double val;
639                 double dualVal;
640 -               stat=lpx_get_col_stat(model,j);
641 -               val=lpx_get_col_prim(model,j);
642 -               dualVal=lpx_get_col_dual(model,j);
643 +               stat=glp_get_col_stat(model,j);
644 +               val=glp_get_col_prim(model,j);
645 +               dualVal=glp_get_col_dual(model,j);
646                 hotStartCStat_[j] = stat;
647                 hotStartCVal_[j] = val;
648                 hotStartCDualVal_[j] = dualVal;
649 @@ -1131,9 +1126,9 @@ void OGSI::markHotStart()
650                 int stat;
651                 double val;
652                 double dualVal;
653 -               stat=lpx_get_row_stat(model,i+1);
654 -               val=lpx_get_row_prim(model,i+1);
655 -               dualVal=lpx_get_row_dual(model,i+1);
656 +               stat=glp_get_row_stat(model,i+1);
657 +               val=glp_get_row_prim(model,i+1);
658 +               dualVal=glp_get_row_dual(model,i+1);
659                 hotStartRStat_[i] = stat;
660                 hotStartRVal_[i] = val;
661                 hotStartRDualVal_[i] = dualVal;
662 @@ -1160,11 +1155,11 @@ void OGSI::solveFromHotStart()
663  
664         int j;
665         for( j = 0; j < numcols; j++ ) {
666 -         lpx_set_col_stat( model, j+1, hotStartCStat_[j]);
667 +         glp_set_col_stat( model, j+1, hotStartCStat_[j]);
668         }
669         int i;
670         for( i = 0; i < numrows; i++ ) {
671 -         lpx_set_row_stat( model, i+1, hotStartRStat_[i]);
672 +         glp_set_row_stat( model, i+1, hotStartRStat_[i]);
673         }
674  
675         freeCachedData( OGSI::FREECACHED_RESULTS );
676 @@ -1191,17 +1186,17 @@ void OGSI::unmarkHotStart()
677  //-----------------------------------------------------------------------------
678  int OGSI::getNumCols() const
679  {
680 -       return lpx_get_num_cols( getMutableModelPtr() );
681 +       return glp_get_num_cols( getMutableModelPtr() );
682  }
683  
684  int OGSI::getNumRows() const
685  {
686 -       return lpx_get_num_rows( getMutableModelPtr() );
687 +       return glp_get_num_rows( getMutableModelPtr() );
688  }
689  
690  int OGSI::getNumElements() const
691  {
692 -       return lpx_get_num_nz( getMutableModelPtr() );
693 +       return glp_get_num_nz( getMutableModelPtr() );
694  }
695  
696  //-----------------------------------------------------------------------------
697 @@ -1230,26 +1225,26 @@ const double * OGSI::getColLower() const
698                         int type;
699                         double lb;
700                         double ub;
701 -                       type=lpx_get_col_type(model,i+1);
702 -                       lb=lpx_get_col_lb(model,i+1);
703 -                       ub=lpx_get_col_ub(model,i+1);
704 +                       type=glp_get_col_type(model,i+1);
705 +                       lb=glp_get_col_lb(model,i+1);
706 +                       ub=glp_get_col_ub(model,i+1);
707                         switch ( type )
708                         {
709 -                       case LPX_FR:
710 +                       case GLP_FR:
711                                 lb = -inf;
712                                 ub = inf;
713                                 break;
714  
715 -                       case LPX_LO:
716 +                       case GLP_LO:
717                                 ub = inf;
718                                 break;
719  
720 -                       case LPX_UP:
721 +                       case GLP_UP:
722                                 lb = -inf;
723                                 break;
724  
725 -                       case LPX_FX:
726 -                       case LPX_DB:
727 +                       case GLP_FX:
728 +                       case GLP_DB:
729                                 break;
730  
731                         default:
732 @@ -1355,26 +1350,26 @@ const double * OGSI::getRowLower() const
733                         int type;
734                         double lb;
735                         double ub;
736 -                       type=lpx_get_row_type(model,i+1);
737 -                       lb=lpx_get_row_lb(model,i+1);
738 -                       ub=lpx_get_row_ub(model,i+1);
739 +                       type=glp_get_row_type(model,i+1);
740 +                       lb=glp_get_row_lb(model,i+1);
741 +                       ub=glp_get_row_ub(model,i+1);
742                         switch( type )
743                         {
744 -                       case LPX_FR:
745 +                       case GLP_FR:
746                                 lb = -inf;
747                                 ub = inf;
748                                 break;
749  
750 -                       case LPX_LO:
751 +                       case GLP_LO:
752                                 ub = inf;
753                                 break;
754  
755 -                       case LPX_UP:
756 +                       case GLP_UP:
757                                 lb = -inf;
758                                 break;
759  
760 -                       case LPX_DB:
761 -                       case LPX_FX:
762 +                       case GLP_DB:
763 +                       case GLP_FX:
764                                 break;
765  
766                         default:
767 @@ -1416,7 +1411,7 @@ const double * OGSI::getObjCoefficients(
768                 int i;
769                 for( i = 0; i < numcols; i++ )
770                 {
771 -                       obj_[i] = lpx_get_obj_coef( model, i + 1);
772 +                       obj_[i] = glp_get_obj_coef( model, i + 1);
773                 }
774         }
775         return obj_;
776 @@ -1426,10 +1421,10 @@ const double * OGSI::getObjCoefficients(
777  
778  double OGSI::getObjSense() const
779  
780 -{ if (lpx_get_obj_dir(lp_) == LPX_MIN)
781 +{ if (glp_get_obj_dir(lp_) == GLP_MIN)
782    { return (+1.0) ; }
783    else
784 -  if (lpx_get_obj_dir(lp_) == LPX_MAX)
785 +  if (glp_get_obj_dir(lp_) == GLP_MAX)
786    { return (-1.0) ; }
787    else // internal confusion
788    { assert(false) ;
789 @@ -1441,7 +1436,7 @@ double OGSI::getObjSense() const
790  
791  bool OGSI::isContinuous( int colNumber ) const
792  {
793 -  return lpx_get_col_kind( getMutableModelPtr(), colNumber+1 ) == LPX_CV;
794 +  return glp_get_col_kind( getMutableModelPtr(), colNumber+1 ) == GLP_CV;
795  }
796  
797  //-----------------------------------------------------------------------------
798 @@ -1464,14 +1459,14 @@ const CoinPackedMatrix * OGSI::getMatrix
799                 int i;
800                 for( i = 0; i < getNumRows(); i++ )
801                 {
802 -                       int colsize = lpx_get_mat_row( model, i+1, colind, colelem);
803 +                       int colsize = glp_get_mat_row( model, i+1, colind, colelem);
804                         int j;
805                         for( j = 1; j <= colsize; j++ )
806                         {
807                                 --colind[j];
808                         }
809  
810 -                       // Note:  lpx_get_mat_row apparently may return the
811 +                       // Note:  glp_get_mat_row apparently may return the
812                         // elements in decreasing order.  This differs from
813                         // people's standard expectations but is not an error.
814  
815 @@ -1502,7 +1497,7 @@ const CoinPackedMatrix * OGSI::getMatrix
816                 int j;
817                 for( j = 0; j < getNumCols(); j++ )
818                 {
819 -                       int rowsize = lpx_get_mat_col( model, j+1, rowind, rowelem);
820 +                       int rowsize = glp_get_mat_col( model, j+1, rowind, rowelem);
821                         int i;
822                         for( i = 1; i <= rowsize; i++ )
823                         {
824 @@ -1563,9 +1558,9 @@ const double *OGSI::getColSolution() con
825  */
826    int probStatus ;
827    if (bbWasLast_)
828 -  { probStatus = lpx_mip_status(lp_) ; }
829 +  { probStatus = glp_mip_status(lp_) ; }
830    else
831 -  { probStatus = lpx_get_status(lp_) ; }
832 +  { probStatus = glp_get_status(lp_) ; }
833  /*
834    If the problem hasn't been solved, glpk returns zeros, but OSI requires that
835    the solution be within bound. getColLower() will ensure both upper and lower
836 @@ -1573,7 +1568,7 @@ const double *OGSI::getColSolution() con
837    collower[j] < colupper[j]). Solution values will be 0.0 unless that's outside
838    the bounds.
839  */
840 -  if (probStatus == LPX_UNDEF || probStatus == LPX_I_UNDEF)
841 +  if (probStatus == GLP_UNDEF)
842    { getColLower() ;
843      int j ;
844      for (j = 0 ; j < numcols ; j++)
845 @@ -1591,10 +1586,10 @@ const double *OGSI::getColSolution() con
846    if (bbWasLast_ == 0)
847    { int j ;
848      for (j = 0 ; j < numcols ; j++)
849 -    { colsol_[j] = lpx_get_col_prim(lp_,j+1) ;
850 +    { colsol_[j] = glp_get_col_prim(lp_,j+1) ;
851        if (fabs(colsol_[j]) < GlpkZeroTol)
852        { colsol_[j] = 0.0 ; }
853 -      redcost_[j] = lpx_get_col_dual(lp_,j+1) ;
854 +      redcost_[j] = glp_get_col_dual(lp_,j+1) ;
855        if (fabs(redcost_[j]) < GlpkZeroTol)
856        { redcost_[j] = 0.0 ; } } }
857  /*
858 @@ -1604,7 +1599,7 @@ const double *OGSI::getColSolution() con
859    else
860    { int j ;
861      for (j = 0 ; j < numcols ; j++)
862 -    { colsol_[j] = lpx_mip_col_val(lp_,j+1) ;
863 +    { colsol_[j] = glp_mip_col_val(lp_,j+1) ;
864        if (fabs(colsol_[j]) < GlpkZeroTol)
865        { colsol_[j] = 0.0 ; }
866        redcost_[j] = 0.0 ; } }
867 @@ -1641,7 +1636,7 @@ const double *OGSI::getRowPrice() const
868    if (bbWasLast_ == 0)
869    { int i ;
870      for (i = 0 ; i < numrows; i++)
871 -    { rowsol_[i] = lpx_get_row_dual(lp_,i+1) ;
872 +    { rowsol_[i] = glp_get_row_dual(lp_,i+1) ;
873        if (fabs(rowsol_[i]) < GlpkZeroTol)
874        { rowsol_[i] = 0.0 ; } } }
875    else
876 @@ -1658,7 +1653,7 @@ const double *OGSI::getRowPrice() const
877    setRowPrice(), and it'd be nice to return reduced costs that agree with the
878    duals.
879  
880 -  To use glpk's routine (lpx_get_col_dual), the interface needs to track the
881 +  To use glpk's routine (glp_get_col_dual), the interface needs to track the
882    origin of the dual (row price) values.
883  */
884  const double * OGSI::getReducedCost() const
885 @@ -1813,7 +1808,7 @@ void OGSI::setObjCoeff (int j, double cj
886  /*
887    Push the changed objective down to glpk.
888  */
889 -  lpx_set_obj_coef(lp_,j+1,cj) ;
890 +  glp_set_obj_coef(lp_,j+1,cj) ;
891  
892    if (obj_)
893    { obj_[j] = cj ; }
894 @@ -1830,15 +1825,15 @@ void OGSI::setColLower (int j, double lb
895    infinite bound, so we need to check the status and possibly correct.
896  */
897    double inf = getInfinity() ;
898 -  int type = lpx_get_col_type(lp_,j+1) ;
899 -  double ubj = lpx_get_col_ub(lp_,j+1) ;
900 +  int type = glp_get_col_type(lp_,j+1) ;
901 +  double ubj = glp_get_col_ub(lp_,j+1) ;
902    switch (type)
903 -  { case LPX_UP:
904 -    case LPX_DB:
905 -    case LPX_FX:
906 +  { case GLP_UP:
907 +    case GLP_DB:
908 +    case GLP_FX:
909      { break ; }
910 -    case LPX_FR:
911 -    case LPX_LO:
912 +    case GLP_FR:
913 +    case GLP_LO:
914      { ubj = inf ;
915        break ; }
916      default:
917 @@ -1875,15 +1870,15 @@ void OGSI::setColUpper (int j, double ub
918    infinite bound, so we need to check the status and possibly correct.
919  */
920    double inf = getInfinity() ;
921 -  int type = lpx_get_col_type(lp_,j+1) ;
922 -  double lbj = lpx_get_col_lb(lp_,j+1) ;
923 +  int type = glp_get_col_type(lp_,j+1) ;
924 +  double lbj = glp_get_col_lb(lp_,j+1) ;
925    switch (type)
926 -  { case LPX_LO:
927 -    case LPX_DB:
928 -    case LPX_FX:
929 +  { case GLP_LO:
930 +    case GLP_DB:
931 +    case GLP_FX:
932      { break ; }
933 -    case LPX_FR:
934 -    case LPX_UP:
935 +    case GLP_FR:
936 +    case GLP_UP:
937      { lbj = inf ;
938        break ; }
939      default:
940 @@ -1932,25 +1927,25 @@ void OGSI::setColBounds (int j, double l
941    int type ;
942  
943    if (lower == upper)
944 -  { type = LPX_FX ; }
945 +  { type = GLP_FX ; }
946    else
947    if (lower > -inf && upper < inf)
948 -  { type = LPX_DB ; }
949 +  { type = GLP_DB ; }
950    else
951    if (lower > -inf)
952 -  { type = LPX_LO ; }
953 +  { type = GLP_LO ; }
954    else
955    if (upper < inf)
956 -  { type = LPX_UP ; }
957 +  { type = GLP_UP ; }
958    else
959 -  { type = LPX_FR ; }
960 +  { type = GLP_FR ; }
961  /*
962    Push the bound change down into the solver. 1-based addressing.
963  */
964 -  int statj = lpx_get_col_stat(lp_,j+1) ;
965 -  lpx_set_col_bnds(lp_,j+1,type,lower,upper) ;
966 -  lpx_set_col_stat(lp_,j+1,statj) ;
967 -  statj = lpx_get_col_stat(lp_,j+1) ;
968 +  int statj = glp_get_col_stat(lp_,j+1) ;
969 +  glp_set_col_bnds(lp_,j+1,type,lower,upper) ;
970 +  glp_set_col_stat(lp_,j+1,statj) ;
971 +  statj = glp_get_col_stat(lp_,j+1) ;
972  /*
973    Correct the cached upper and lower bound vectors, if present.
974  */
975 @@ -1982,18 +1977,18 @@ OGSI::setRowLower( int elementIndex, dou
976         double lb;
977         double ub;
978  
979 -       type=lpx_get_row_type(getMutableModelPtr(),elementIndex+1);
980 -       ub=lpx_get_row_ub(getMutableModelPtr(),elementIndex+1);
981 +       type=glp_get_row_type(getMutableModelPtr(),elementIndex+1);
982 +       ub=glp_get_row_ub(getMutableModelPtr(),elementIndex+1);
983         lb = elementValue;
984         switch( type )
985         {
986 -       case LPX_UP:
987 -       case LPX_DB:
988 -       case LPX_FX:
989 +       case GLP_UP:
990 +       case GLP_DB:
991 +       case GLP_FX:
992                 break;
993  
994 -       case LPX_FR:
995 -       case LPX_LO:
996 +       case GLP_FR:
997 +       case GLP_LO:
998                 ub = inf;
999                 break;
1000  
1001 @@ -2014,18 +2009,18 @@ OGSI::setRowUpper( int elementIndex, dou
1002         double lb;
1003         double ub;
1004  
1005 -       type=lpx_get_row_type(getMutableModelPtr(),elementIndex+1);
1006 -       lb=lpx_get_row_lb(getMutableModelPtr(),elementIndex+1);
1007 +       type=glp_get_row_type(getMutableModelPtr(),elementIndex+1);
1008 +       lb=glp_get_row_lb(getMutableModelPtr(),elementIndex+1);
1009         ub = elementValue;
1010         switch( type )
1011         {
1012 -       case LPX_LO:
1013 -       case LPX_DB:
1014 -       case LPX_FX:
1015 +       case GLP_LO:
1016 +       case GLP_DB:
1017 +       case GLP_FX:
1018                 break;
1019  
1020 -       case LPX_FR:
1021 -       case LPX_UP:
1022 +       case GLP_FR:
1023 +       case GLP_UP:
1024                 lb = -inf;
1025                 break;
1026  
1027 @@ -2056,20 +2051,20 @@ void OGSI::setRowBounds (int i, double l
1028    int type ;
1029  
1030    if( lower == upper)
1031 -  { type = LPX_FX ; }
1032 +  { type = GLP_FX ; }
1033    else
1034    if (lower > -inf && upper < inf)
1035 -  { type = LPX_DB ; }
1036 +  { type = GLP_DB ; }
1037    else
1038    if (lower > -inf)
1039 -  { type = LPX_LO ; }
1040 +  { type = GLP_LO ; }
1041    else
1042    if (upper < inf)
1043 -  { type = LPX_UP ; }
1044 +  { type = GLP_UP ; }
1045    else
1046 -  { type = LPX_FR ; }
1047 +  { type = GLP_FR ; }
1048  
1049 -  lpx_set_row_bnds(lp_,i+1,type,lower,upper) ;
1050 +  glp_set_row_bnds(lp_,i+1,type,lower,upper) ;
1051  /*
1052    Update cached vectors, if they exist.
1053  */
1054 @@ -2123,7 +2118,7 @@ OGSI::setContinuous(int index)
1055  {
1056          LPX *model = getMutableModelPtr();
1057         freeCachedData( OGSI::FREECACHED_COLUMN );
1058 -       lpx_set_col_kind( model, index+1, LPX_CV );
1059 +       glp_set_col_kind( model, index+1, GLP_CV );
1060  }
1061  
1062  //-----------------------------------------------------------------------------
1063 @@ -2132,7 +2127,7 @@ void OGSI::setInteger (int index)
1064  
1065  { LPX *model = getMutableModelPtr() ;
1066    freeCachedData(OGSI::FREECACHED_COLUMN) ;
1067 -  lpx_set_col_kind(model,index+1,LPX_IV) ;
1068 +  glp_set_col_kind(model,index+1,GLP_IV) ;
1069  /*
1070    Temporary hack to correct upper bounds on general integer variables.
1071    CoinMpsIO insists on forcing a bound of 1e30 for general integer variables
1072 @@ -2184,9 +2179,9 @@ void OGSI::setObjSense(double s)
1073  { freeCachedData(OGSI::FREECACHED_RESULTS) ;
1074  
1075    if (s <= -1.0)
1076 -  { lpx_set_obj_dir(lp_,LPX_MAX) ; }
1077 +  { glp_set_obj_dir(lp_,GLP_MAX) ; }
1078    else
1079 -  { lpx_set_obj_dir(lp_,LPX_MIN) ; }
1080 +  { glp_set_obj_dir(lp_,GLP_MIN) ; }
1081  
1082    return ; }
1083  
1084 @@ -2252,12 +2247,12 @@ void OGSI::addCol (const CoinPackedVecto
1085                    const double collb, const double colub, const double obj)
1086  {
1087    // Note: GLPK expects only non-zero coefficients will be given in 
1088 -  //   lpx_set_mat_col and will abort if there are any zeros.  So any
1089 -  //   zeros must be removed prior to calling lpx_set_mat_col.
1090 +  //   glp_set_mat_col and will abort if there are any zeros.  So any
1091 +  //   zeros must be removed prior to calling glp_set_mat_col.
1092          LPX *model = getMutableModelPtr();
1093         freeCachedData(OGSI::KEEPCACHED_ROW);
1094  
1095 -       lpx_add_cols( model, 1 );
1096 +       glp_add_cols( model, 1 );
1097         int numcols = getNumCols();
1098         setColBounds( numcols-1, collb, colub );
1099         setObjCoeff( numcols-1, obj );
1100 @@ -2276,7 +2271,7 @@ void OGSI::addCol (const CoinPackedVecto
1101           if (elements[i] != 0.0)
1102             {
1103                 if ( indices[i]+1 > numrows ) {
1104 -                       lpx_add_rows( model, indices[i]+1 - numrows );
1105 +                       glp_add_rows( model, indices[i]+1 - numrows );
1106                         numrows = indices[i]+1;
1107                         // ??? could do this more efficiently with a single call based on the max
1108                 }
1109 @@ -2286,7 +2281,7 @@ void OGSI::addCol (const CoinPackedVecto
1110                 elements_adj[count] = elements[i];
1111             }
1112         }
1113 -       lpx_set_mat_col( model, numcols, count, indices_adj, elements_adj );
1114 +       glp_set_mat_col( model, numcols, count, indices_adj, elements_adj );
1115         delete [] indices_adj;
1116         delete [] elements_adj;
1117  
1118 @@ -2326,7 +2321,7 @@ OGSI::deleteCols(const int num, const in
1119                 columnIndicesPlus1[i+1]=columnIndices[i]+1;
1120                 deleteColNames(columnIndices[i],1);
1121         }
1122 -       lpx_del_cols(model,num,columnIndicesPlus1);
1123 +       glp_del_cols(model,num,columnIndicesPlus1);
1124         delete [] columnIndicesPlus1;
1125  
1126  # if OGSI_TRACK_FRESH > 0
1127 @@ -2344,13 +2339,13 @@ OGSI::addRow (const CoinPackedVectorBase
1128               const double rowlb, const double rowub)
1129  {
1130    // Note: GLPK expects only non-zero coefficients will be given in 
1131 -  //   lpx_set_mat_row and will abort if there are any zeros.  So any
1132 -  //   zeros must be removed prior to calling lpx_set_mat_row.
1133 +  //   glp_set_mat_row and will abort if there are any zeros.  So any
1134 +  //   zeros must be removed prior to calling glp_set_mat_row.
1135  
1136          LPX *model = getMutableModelPtr();
1137         freeCachedData( OGSI::KEEPCACHED_COLUMN );
1138  
1139 -       lpx_add_rows( model, 1 );
1140 +       glp_add_rows( model, 1 );
1141         int numrows = getNumRows();
1142         setRowBounds( numrows-1, rowlb, rowub );
1143         int i;
1144 @@ -2369,7 +2364,7 @@ OGSI::addRow (const CoinPackedVectorBase
1145             {
1146                 if ( indices[i]+1 > numcols ) {
1147                   // ??? Could do this more efficiently with a single call
1148 -                       lpx_add_cols( model, indices[i]+1 - numcols );
1149 +                       glp_add_cols( model, indices[i]+1 - numcols );
1150                         numcols = indices[i]+1;
1151                 }
1152                 count++;
1153 @@ -2377,7 +2372,7 @@ OGSI::addRow (const CoinPackedVectorBase
1154                 indices_adj[count] = indices[i] + 1;
1155             }
1156         }
1157 -       lpx_set_mat_row( model, numrows, count, indices_adj, elements_adj );
1158 +       glp_set_mat_row( model, numrows, count, indices_adj, elements_adj );
1159         delete [] indices_adj;
1160         delete [] elements_adj;
1161  
1162 @@ -2461,8 +2456,8 @@ void OGSI::deleteRows (const int num, co
1163    int notBasic = 0 ;
1164    for (ndx = 1 ; ndx <= num ; ndx++)
1165    { i = glpkIndices[ndx] ;
1166 -    int stati = lpx_get_row_stat(lp_,i) ;
1167 -    if (stati != LPX_BS)
1168 +    int stati = glp_get_row_stat(lp_,i) ;
1169 +    if (stati != GLP_BS)
1170      { notBasic++ ; } }
1171    if (notBasic)
1172    {
1173 @@ -2476,7 +2471,7 @@ void OGSI::deleteRows (const int num, co
1174  /*
1175    Tell glpk to delete the rows.
1176  */
1177 -  lpx_del_rows(lp_,num,glpkIndices) ;
1178 +  glp_del_rows(lp_,num,glpkIndices) ;
1179  
1180    delete [] glpkIndices ;
1181  
1182 @@ -2511,41 +2506,32 @@ void OGSI::loadProblem (const CoinPacked
1183    
1184    In any event, get rid of cached data in the OsiGlpk object.
1185  */
1186 -  if (lpx_get_num_cols(lp_) != 0 || lpx_get_num_rows(lp_) != 0)
1187 +  if (glp_get_num_cols(lp_) != 0 || glp_get_num_rows(lp_) != 0)
1188    { 
1189 -    int presolVal = lpx_get_int_parm(lp_,LPX_K_PRESOL) ;
1190 -    int usedualVal = lpx_get_int_parm(lp_,LPX_K_DUAL) ;
1191 -    int scaleVal = lpx_get_int_parm(lp_,LPX_K_SCALE) ;
1192 -    int logVal = lpx_get_int_parm(lp_,LPX_K_MSGLEV) ;
1193  #   if OGSI_TRACK_FRESH > 0
1194      std::cout
1195        << "    emptying LPX(" << std::hex << lp_ << std::dec << "), "
1196  #   endif
1197 -    lpx_delete_prob(lp_) ;
1198 -    lp_ = lpx_create_prob() ;
1199 +    glp_delete_prob(lp_) ;
1200 +    lp_ = glp_create_prob() ;
1201      assert(lp_) ;
1202  #   if OGSI_TRACK_FRESH > 0
1203      std::cout
1204        << "loading LPX(" << std::hex << lp_ << std::dec << ")."
1205        << std::endl ;
1206  #   endif
1207 -    lpx_set_class(lp_,LPX_MIP) ;
1208 -    lpx_set_int_parm(lp_,LPX_K_ITLIM,maxIteration_) ; 
1209 +    
1210 +    simplexParams_.it_lim = maxIteration_ ; 
1211      if (getObjSense() == 1)                            // minimization
1212 -    { lpx_set_real_parm(lp_,LPX_K_OBJUL,dualObjectiveLimit_) ;
1213 -      lpx_set_real_parm(lp_,LPX_K_OBJLL,primalObjectiveLimit_) ; }
1214 +    { simplexParams_.obj_ul = dualObjectiveLimit_ ;
1215 +      simplexParams_.obj_ll = primalObjectiveLimit_ ; }
1216      else                                               // maximization
1217 -    { lpx_set_real_parm(lp_,LPX_K_OBJLL,dualObjectiveLimit_) ;
1218 -      lpx_set_real_parm(lp_,LPX_K_OBJUL,primalObjectiveLimit_) ; }
1219 -    lpx_set_real_parm(lp_,LPX_K_TOLDJ,dualTolerance_) ;
1220 -    lpx_set_real_parm(lp_,LPX_K_TOLBND,primalTolerance_) ;
1221 -    lpx_set_obj_coef(lp_,0,objOffset_) ;
1222 -    lpx_set_prob_name(lp_,const_cast<char *>(probName_.c_str())) ;
1223 -    lpx_set_int_parm(lp_,LPX_K_PRESOL,presolVal) ;
1224 -    lpx_set_int_parm(lp_,LPX_K_DUAL,usedualVal) ;
1225 -    lpx_set_int_parm(lp_,LPX_K_SCALE,scaleVal) ;
1226 -    lpx_set_int_parm(lp_,LPX_K_MSGLEV,logVal) ;
1227 -    messageHandler()->setLogLevel(logVal) ; }
1228 +    { simplexParams_.obj_ll = dualObjectiveLimit_ ;
1229 +      simplexParams_.obj_ul = primalObjectiveLimit_ ; }
1230 +    simplexParams_.tol_dj = dualTolerance_ ;
1231 +    simplexParams_.tol_bnd = primalTolerance_ ;
1232 +    glp_set_obj_coef(lp_,0,objOffset_) ;
1233 +    glp_set_prob_name(lp_,const_cast<char *>(probName_.c_str())) ; }
1234  
1235    freeCachedData(OGSI::KEEPCACHED_NONE) ;
1236  
1237 @@ -2617,7 +2603,7 @@ void OGSI::loadProblem (const CoinPacked
1238        addCol(reqdBySunCC,collb[j],colub[j],obj[j]) ; }
1239      // Make sure there are enough rows 
1240      if (m > getNumRows())
1241 -    { lpx_add_rows(lp_,m-getNumRows()) ; }
1242 +    { glp_add_rows(lp_,m-getNumRows()) ; }
1243      for (i = 0 ; i < m ; i++)
1244      { setRowBounds(i,rowlb[i],rowub[i]) ; } }
1245    else
1246 @@ -2626,7 +2612,7 @@ void OGSI::loadProblem (const CoinPacked
1247        addRow(reqdBySunCC,rowlb[i],rowub[i]) ; }
1248      // Make sure there are enough columns
1249      if (n > getNumCols())
1250 -    { lpx_add_cols(lp_,n-getNumCols()) ; }
1251 +    { glp_add_cols(lp_,n-getNumCols()) ; }
1252      for (j = 0 ; j < n ; j++)
1253      { setColBounds(j,collb[j],colub[j]) ;
1254        setObjCoeff(j,obj[j]) ; } }
1255 @@ -2731,11 +2717,11 @@ OGSI::loadProblem(const int numcols, con
1256    LPX *model = getMutableModelPtr();
1257    double inf = getInfinity();
1258  
1259 -  // Can't send 0 to lpx_add_xxx
1260 +  // Can't send 0 to glp_add_xxx
1261    if (numcols > 0)
1262 -    lpx_add_cols( model, numcols );
1263 +    glp_add_cols( model, numcols );
1264    if (numrows > 0)
1265 -    lpx_add_rows( model, numrows );
1266 +    glp_add_rows( model, numrows );
1267  
1268    // How many elements?  Column-major, so indices of start are columns
1269    int numelem = start[ numcols ];
1270 @@ -2756,7 +2742,7 @@ OGSI::loadProblem(const int numcols, con
1271    {
1272         setColBounds( i, collb ? collb[i]:0.0, 
1273                     colub ? colub[i]:inf );
1274 -       lpx_set_mat_col( model, i+1, start[i+1]-start[i], &(index_adj[start[i]]), &(value_adj[start[i]]) );
1275 +       glp_set_mat_col( model, i+1, start[i+1]-start[i], &(index_adj[start[i]]), &(value_adj[start[i]]) );
1276      setObjCoeff( i, obj ? obj[i]:0.0 );
1277    }
1278    int j;
1279 @@ -2823,7 +2809,7 @@ void OGSI::writeMps( const char * filena
1280         std::string f( filename );
1281         std::string e( extension );
1282         std::string fullname = f + "." + e;
1283 -       lpx_write_mps( getMutableModelPtr(), const_cast<char*>( fullname.c_str() ));
1284 +       glp_write_mps( getMutableModelPtr(), GLP_MPS_FILE, NULL, const_cast<char*>( fullname.c_str() ));
1285  #else
1286         // Fall back on native MPS writer.  
1287         // These few lines of code haven't been tested. 2004/10/15
1288 @@ -2996,17 +2982,17 @@ void OGSI::applyColCut( const OsiColCut
1289              // update cached version as well
1290              collower_[column] = lower;
1291              if( lower == upper )
1292 -              type = LPX_FX;
1293 +              type = GLP_FX;
1294              else if( lower > -inf && upper < inf )
1295 -              type = LPX_DB;
1296 +              type = GLP_DB;
1297              else if( lower > -inf )
1298 -              type = LPX_LO;
1299 +              type = GLP_LO;
1300              else if( upper < inf)
1301 -              type = LPX_UP;
1302 +              type = GLP_UP;
1303              else
1304 -              type = LPX_FR;
1305 +              type = GLP_FR;
1306              
1307 -            lpx_set_col_bnds( getMutableModelPtr(), column+1, type, lower, upper );
1308 +            glp_set_col_bnds( getMutableModelPtr(), column+1, type, lower, upper );
1309            }
1310          }
1311          // lower bounds
1312 @@ -3018,17 +3004,17 @@ void OGSI::applyColCut( const OsiColCut
1313              // update cached version as well
1314              colupper_[column] = upper;
1315              if( lower == upper )
1316 -              type = LPX_FX;
1317 +              type = GLP_FX;
1318              else if( lower > -inf && upper < inf )
1319 -              type = LPX_DB;
1320 +              type = GLP_DB;
1321              else if( lower > -inf )
1322 -              type = LPX_LO;
1323 +              type = GLP_LO;
1324              else if( upper < inf)
1325 -              type = LPX_UP;
1326 +              type = GLP_UP;
1327              else
1328 -              type = LPX_FR;
1329 +              type = GLP_FR;
1330              
1331 -            lpx_set_col_bnds( getMutableModelPtr(), column+1, type, lower, upper );
1332 +            glp_set_col_bnds( getMutableModelPtr(), column+1, type, lower, upper );
1333            }
1334          }
1335  #endif
1336 @@ -3095,25 +3081,24 @@ void OGSI::gutsOfCopy (const OsiGlpkSolv
1337    held up on the parent OSI object, so we don't need to worry about copying
1338    them.
1339  */
1340 -  intParam = lpx_get_int_parm(srclpx,LPX_K_PRESOL) ;
1341 -  lpx_set_int_parm(lpx,LPX_K_PRESOL,intParam) ;
1342 -  intParam = lpx_get_int_parm(srclpx,LPX_K_DUAL) ;
1343 -  lpx_set_int_parm(lpx,LPX_K_DUAL,intParam) ;
1344 -  intParam = lpx_get_int_parm(srclpx,LPX_K_SCALE) ;
1345 -  lpx_set_int_parm(lpx,LPX_K_SCALE,intParam) ;
1346 +  intoptParams_.presolve = source.intoptParams_.presolve;
1347 +  simplexParams_.presolve = source.simplexParams_.presolve;
1348 +  simplexParams_.meth = source.simplexParams_.meth;
1349 +  scaleFlags_ = source.scaleFlags_;
1350  /*
1351    Printing is a bit more complicated. Pull the parameter and set the log
1352    level in the message handler and set the print parameter in glpk.
1353  */
1354 -  intParam = lpx_get_int_parm(srclpx,LPX_K_MSGLEV) ;
1355 -  lpx_set_int_parm(lpx,LPX_K_MSGLEV,intParam) ;
1356 -  messageHandler()->setLogLevel(intParam) ;
1357 -
1358 -# ifdef LPX_K_USECUTS
1359 -  intParam=lpx_get_int_parm(lp_,LPX_K_USECUTS);
1360 -  lpx_set_int_parm(lp_,LPX_K_USECUTS,intParam);
1361 -# endif
1362 +  simplexParams_.msg_lev = source.simplexParams_.msg_lev;
1363 +  intoptParams_.msg_lev = source.intoptParams_.msg_lev;
1364 +  messageHandler()->setLogLevel(simplexParams_.msg_lev) ;
1365 +
1366 +  intoptParams_.mir_cuts = source.intoptParams_.mir_cuts;
1367 +  intoptParams_.gmi_cuts = source.intoptParams_.gmi_cuts;
1368 +  intoptParams_.cov_cuts = source.intoptParams_.cov_cuts;
1369 +  intoptParams_.clq_cuts = source.intoptParams_.clq_cuts;
1370    
1371 +  glp_scale_prob(lp_, scaleFlags_);
1372  /*
1373    Now --- do we have a problem loaded? If not, we're done.
1374  */
1375 @@ -3164,22 +3149,22 @@ void OGSI::gutsOfCopy (const OsiGlpkSolv
1376    nonsense, then don't bother. Once we've copied the status into the new lpx
1377    object, do the warm-up.
1378  */
1379 -  if (lpx_get_status(srclpx) != LPX_UNDEF)
1380 +  if (glp_get_status(srclpx) != GLP_UNDEF)
1381    { for (j = 1 ; j <= n ; j++)
1382 -    { int statj = lpx_get_col_stat(srclpx,j) ;
1383 -      lpx_set_col_stat(lpx,j,statj) ; }
1384 +    { int statj = glp_get_col_stat(srclpx,j) ;
1385 +      glp_set_col_stat(lpx,j,statj) ; }
1386      for (i = 1 ; i <= m ; i++)
1387 -    { int stati = lpx_get_row_stat(srclpx,i) ;
1388 -      lpx_set_row_stat(lpx,i,stati) ; }
1389 +    { int stati = glp_get_row_stat(srclpx,i) ;
1390 +      glp_set_row_stat(lpx,i,stati) ; }
1391  
1392  #ifndef NDEBUG
1393 -    int retval = lpx_warm_up(lpx) ;
1394 +    int retval = glp_warm_up(lpx) ;
1395  #endif
1396  #   if OGSI_TRACK_SOLVERS > 1
1397      std::cout
1398 -      << "    lpx_warm_up returns " << retval << "." << std::endl ;
1399 +      << "    glp_warm_up returns " << retval << "." << std::endl ;
1400  #   endif
1401 -    assert(retval == LPX_E_OK) ; }
1402 +    assert(retval == 0) ; }
1403  
1404    return ; }
1405  
1406 @@ -3232,26 +3217,28 @@ void OGSI::gutsOfConstructor()
1407    isObjUpperLimitReached_ = false ;
1408    isFeasible_ = false;
1409  
1410 -  lp_ = lpx_create_prob();
1411 +  lp_ = glp_create_prob();
1412    assert( lp_ != NULL );
1413 -  // Make all problems MIPs.  See note at top of file.
1414 -  lpx_set_class( lp_, LPX_MIP );
1415  
1416 +  glp_init_smcp(&simplexParams_);
1417 +  glp_init_iocp(&intoptParams_);
1418 +  scaleFlags_ = GLP_SF_EQ;
1419 +  glp_scale_prob(lp_, scaleFlags_);
1420    // Push OSI parameters down into LPX object.
1421 -  lpx_set_int_parm(lp_,LPX_K_ITLIM,maxIteration_) ; 
1422 +  simplexParams_.it_lim = maxIteration_;
1423  
1424    if (getObjSense() == 1.0)                            // minimization
1425 -  { lpx_set_real_parm(lp_,LPX_K_OBJUL,dualObjectiveLimit_) ;
1426 -    lpx_set_real_parm(lp_,LPX_K_OBJLL,primalObjectiveLimit_) ; }
1427 +  { simplexParams_.obj_ul = dualObjectiveLimit_ ;
1428 +    simplexParams_.obj_ll = primalObjectiveLimit_ ; }
1429    else                                         // maximization
1430 -  { lpx_set_real_parm(lp_,LPX_K_OBJLL,dualObjectiveLimit_) ;
1431 -    lpx_set_real_parm(lp_,LPX_K_OBJUL,-primalObjectiveLimit_) ; }
1432 -  lpx_set_real_parm(lp_,LPX_K_TOLDJ,dualTolerance_) ;
1433 -  lpx_set_real_parm(lp_,LPX_K_TOLBND,primalTolerance_) ;
1434 +  { simplexParams_.obj_ll = dualObjectiveLimit_ ;
1435 +    simplexParams_.obj_ul = -primalObjectiveLimit_ ; }
1436 +  simplexParams_.tol_dj = dualTolerance_;
1437 +  simplexParams_.tol_bnd = primalTolerance_;
1438  
1439 -  lpx_set_obj_coef(lp_,0,objOffset_) ;
1440 +  glp_set_obj_coef(lp_,0,objOffset_) ;
1441  
1442 -  lpx_set_prob_name(lp_,const_cast<char *>(probName_.c_str())) ;
1443 +  glp_set_prob_name(lp_,const_cast<char *>(probName_.c_str())) ;
1444  
1445  /* Stefan: with the new simplex algorithm in Glpk 4.31, some netlib instances (e.g., dfl001)
1446     take very long or get into a cycle.
1447 @@ -3264,22 +3251,16 @@ void OGSI::gutsOfConstructor()
1448    Printing is a bit more complicated. Set the log level in the handler and set
1449    the print parameter in glpk.
1450  */
1451 -  lpx_set_int_parm(lp_,LPX_K_MSGLEV,1) ;
1452 -  messageHandler()->setLogLevel(1) ;
1453 +  simplexParams_.msg_lev = intoptParams_.msg_lev = GLP_MSG_ERR ;
1454 +  messageHandler()->setLogLevel(GLP_MSG_ERR) ;
1455    
1456  /*
1457 -  Enable cuts if they're available. This is a bit of a pain,
1458 -  as the interface has changed since it was first introduced in 4.9.
1459 -  LPX_K_USECUTS appears in 4.9; the parameter value
1460 -  appears to be unused in this version. LPX_C_ALL appears in 4.10.
1461 -*/
1462 -# ifdef LPX_K_USECUTS
1463 -# ifdef LPX_C_ALL
1464 -  lpx_set_int_parm(lp_,LPX_K_USECUTS,LPX_C_ALL) ;
1465 -# else
1466 -  lpx_set_int_parm(lp_,LPX_K_USECUTS,0) ;
1467 -# endif
1468 -# endif
1469 +  Enable cuts if they're available.
1470 +*/
1471 +  intoptParams_.mir_cuts = GLP_ON;
1472 +  intoptParams_.gmi_cuts = GLP_ON;
1473 +  intoptParams_.cov_cuts = GLP_ON;
1474 +  intoptParams_.clq_cuts = GLP_ON;
1475  }
1476  
1477  //-----------------------------------------------------------------------------
1478 @@ -3288,7 +3269,7 @@ void OGSI::gutsOfDestructor()
1479  {
1480         if( lp_ != NULL )
1481         {
1482 -               lpx_delete_prob( lp_ );
1483 +               glp_delete_prob( lp_ );
1484                 lp_=NULL;
1485                 freeAllMemory();
1486         }
1487 @@ -3408,7 +3389,7 @@ void OGSI::freeAllMemory()
1488  void OGSI::setObjName (std::string name)
1489  
1490  { OsiSolverInterface::setObjName(name) ;
1491 -  lpx_set_obj_name(lp_,const_cast<char *>(name.c_str())) ; }
1492 +  glp_set_obj_name(lp_,const_cast<char *>(name.c_str())) ; }
1493  
1494  /*!
1495    Set a row name. Make sure both glpk and OSI see the same name.
1496 @@ -3431,7 +3412,7 @@ void OGSI::setRowName (int ndx, std::str
1497    Set the name in the OSI base, then in the consys structure.
1498  */
1499    OsiSolverInterface::setRowName(ndx,name) ;
1500 -  lpx_set_row_name(lp_,ndx+1,const_cast<char *>(name.c_str())) ;
1501 +  glp_set_row_name(lp_,ndx+1,const_cast<char *>(name.c_str())) ;
1502  
1503    return ; }
1504  
1505 @@ -3456,7 +3437,7 @@ void OGSI::setColName (int ndx, std::str
1506    Set the name in the OSI base, then in the consys structure.
1507  */
1508    OsiSolverInterface::setColName(ndx,name) ;
1509 -  lpx_set_col_name(lp_,ndx+1,const_cast<char *>(name.c_str())) ;
1510 +  glp_set_col_name(lp_,ndx+1,const_cast<char *>(name.c_str())) ;
1511  
1512    return ; }
1513  
1514 --- Osi-0.106.10/Osi/src/OsiGlpk/OsiGlpkSolverInterface.hpp.orig        2013-04-06 14:50:19.000000000 +0200
1515 +++ Osi-0.106.10/Osi/src/OsiGlpk/OsiGlpkSolverInterface.hpp     2014-12-03 20:33:20.066812529 +0100
1516 @@ -768,6 +768,9 @@ private:
1517    //@{
1518    /// GPLK model represented by this class instance
1519    mutable LPX* lp_;
1520 +  glp_iocp intoptParams_;
1521 +  glp_smcp simplexParams_;
1522 +  int scaleFlags_;
1523    
1524    /// number of GLPK instances currently in use (counts only those created by OsiGlpk) 
1525    static unsigned int numInstances_;
This page took 0.237822 seconds and 3 git commands to generate.