source: branches/BSP/trunk/Clp/src/CbcOrClpParam.cpp @ 1069

Last change on this file since 1069 was 1061, checked in by forrest, 13 years ago

nonlinear and a few parameters

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 94.9 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#if defined(_MSC_VER)
4// Turn off compiler warning about long names
5#  pragma warning(disable:4786)
6#endif
7
8#include "CbcOrClpParam.hpp"
9
10#include <string>
11#include <iostream>
12#include <cassert>
13
14#ifdef COIN_HAS_CBC
15#ifdef COIN_HAS_CLP
16#include "OsiClpSolverInterface.hpp"
17#include "ClpSimplex.hpp"
18#endif
19#include "CbcModel.hpp"
20#endif
21#ifdef COIN_HAS_CLP
22#include "ClpSimplex.hpp"
23#include "ClpFactorization.hpp"
24#endif
25#ifdef COIN_HAS_READLINE     
26#include <readline/readline.h>
27#include <readline/history.h>
28#endif
29#ifdef COIN_HAS_CBC
30// from CoinSolve
31static char coin_prompt[]="Coin:";
32#else
33static char coin_prompt[]="Clp:";
34#endif
35static bool doPrinting=true;
36std::string afterEquals="";
37void setCbcOrClpPrinting(bool yesNo)
38{
39  doPrinting=yesNo;
40}
41//#############################################################################
42// Constructors / Destructor / Assignment
43//#############################################################################
44
45//-------------------------------------------------------------------
46// Default Constructor
47//-------------------------------------------------------------------
48CbcOrClpParam::CbcOrClpParam () 
49  : type_(INVALID),
50    lowerDoubleValue_(0.0),
51    upperDoubleValue_(0.0),
52    lowerIntValue_(0),
53    upperIntValue_(0),
54    lengthName_(0),
55    lengthMatch_(0),
56    definedKeyWords_(),
57    name_(),
58    shortHelp_(),
59    longHelp_(),
60    action_(INVALID),
61    currentKeyWord_(-1),
62    display_(false),
63    intValue_(-1),
64    doubleValue_(-1.0),
65    stringValue_(""),
66    whereUsed_(7)
67{
68}
69// Other constructors
70CbcOrClpParam::CbcOrClpParam (std::string name, std::string help,
71           double lower, double upper, CbcOrClpParameterType type,
72                    bool display)
73  : type_(type),
74    lowerIntValue_(0),
75    upperIntValue_(0),
76    definedKeyWords_(),
77    name_(name),
78    shortHelp_(help),
79    longHelp_(),
80    action_(type),
81    currentKeyWord_(-1),
82    display_(display),
83    intValue_(-1),
84    doubleValue_(-1.0),
85    stringValue_(""),
86    whereUsed_(7)
87{
88  lowerDoubleValue_ = lower;
89  upperDoubleValue_ = upper;
90  gutsOfConstructor();
91}
92CbcOrClpParam::CbcOrClpParam (std::string name, std::string help,
93           int lower, int upper, CbcOrClpParameterType type,
94                    bool display)
95  : type_(type),
96    lowerDoubleValue_(0.0),
97    upperDoubleValue_(0.0),
98    definedKeyWords_(),
99    name_(name),
100    shortHelp_(help),
101    longHelp_(),
102    action_(type),
103    currentKeyWord_(-1),
104    display_(display),
105    intValue_(-1),
106    doubleValue_(-1.0),
107    stringValue_(""),
108    whereUsed_(7)
109{
110  gutsOfConstructor();
111  lowerIntValue_ = lower;
112  upperIntValue_ = upper;
113}
114// Other strings will be added by append
115CbcOrClpParam::CbcOrClpParam (std::string name, std::string help, 
116                    std::string firstValue,
117                    CbcOrClpParameterType type,int whereUsed,
118                    bool display)
119  : type_(type),
120    lowerDoubleValue_(0.0),
121    upperDoubleValue_(0.0),
122    lowerIntValue_(0),
123    upperIntValue_(0),
124    definedKeyWords_(),
125    name_(name),
126    shortHelp_(help),
127    longHelp_(),
128    action_(type),
129    currentKeyWord_(0),
130    display_(display),
131    intValue_(-1),
132    doubleValue_(-1.0),
133    stringValue_(""),
134    whereUsed_(whereUsed)
135{
136  gutsOfConstructor();
137  definedKeyWords_.push_back(firstValue);
138}
139// Action
140CbcOrClpParam::CbcOrClpParam (std::string name, std::string help,
141                    CbcOrClpParameterType type,int whereUsed,
142                    bool display)
143  : type_(type),
144    lowerDoubleValue_(0.0),
145    upperDoubleValue_(0.0),
146    lowerIntValue_(0),
147    upperIntValue_(0),
148    definedKeyWords_(),
149    name_(name),
150    shortHelp_(help),
151    longHelp_(),
152    action_(type),
153    currentKeyWord_(-1),
154    display_(display),
155    intValue_(-1),
156    doubleValue_(-1.0),
157    stringValue_("")
158{
159  whereUsed_=whereUsed;
160  gutsOfConstructor();
161}
162
163//-------------------------------------------------------------------
164// Copy constructor
165//-------------------------------------------------------------------
166CbcOrClpParam::CbcOrClpParam (const CbcOrClpParam & rhs) 
167{ 
168  type_ = rhs.type_;
169  lowerDoubleValue_ = rhs.lowerDoubleValue_;
170  upperDoubleValue_ = rhs.upperDoubleValue_;
171  lowerIntValue_ = rhs.lowerIntValue_;
172  upperIntValue_ = rhs.upperIntValue_;
173  lengthName_ = rhs.lengthName_;
174  lengthMatch_ = rhs.lengthMatch_;
175  definedKeyWords_ = rhs.definedKeyWords_;
176  name_ = rhs.name_;
177  shortHelp_ = rhs.shortHelp_;
178  longHelp_ = rhs.longHelp_;
179  action_ = rhs.action_;
180  currentKeyWord_ = rhs.currentKeyWord_;
181  display_=rhs.display_;
182  intValue_=rhs.intValue_;
183  doubleValue_=rhs.doubleValue_;
184  stringValue_=rhs.stringValue_;
185  whereUsed_=rhs.whereUsed_;
186}
187
188//-------------------------------------------------------------------
189// Destructor
190//-------------------------------------------------------------------
191CbcOrClpParam::~CbcOrClpParam ()
192{
193}
194
195//----------------------------------------------------------------
196// Assignment operator
197//-------------------------------------------------------------------
198CbcOrClpParam &
199CbcOrClpParam::operator=(const CbcOrClpParam& rhs)
200{
201  if (this != &rhs) {
202    type_ = rhs.type_;
203    lowerDoubleValue_ = rhs.lowerDoubleValue_;
204    upperDoubleValue_ = rhs.upperDoubleValue_;
205    lowerIntValue_ = rhs.lowerIntValue_;
206    upperIntValue_ = rhs.upperIntValue_;
207    lengthName_ = rhs.lengthName_;
208    lengthMatch_ = rhs.lengthMatch_;
209    definedKeyWords_ = rhs.definedKeyWords_;
210    name_ = rhs.name_;
211    shortHelp_ = rhs.shortHelp_;
212    longHelp_ = rhs.longHelp_;
213    action_ = rhs.action_;
214    currentKeyWord_ = rhs.currentKeyWord_;
215    display_=rhs.display_;
216    intValue_=rhs.intValue_;
217    doubleValue_=rhs.doubleValue_;
218    stringValue_=rhs.stringValue_;
219    whereUsed_=rhs.whereUsed_;
220  }
221  return *this;
222}
223void 
224CbcOrClpParam::gutsOfConstructor()
225{
226  std::string::size_type  shriekPos = name_.find('!');
227  lengthName_ = name_.length();
228  if ( shriekPos==std::string::npos ) {
229    //does not contain '!'
230    lengthMatch_= lengthName_;
231  } else {
232    lengthMatch_=shriekPos;
233    name_ = name_.substr(0,shriekPos)+name_.substr(shriekPos+1);
234    lengthName_--;
235  }
236}
237// Insert string (only valid for keywords)
238void 
239CbcOrClpParam::append(std::string keyWord)
240{
241  definedKeyWords_.push_back(keyWord);
242}
243
244int 
245CbcOrClpParam::matches (std::string input) const
246{
247  // look up strings to do more elegantly
248  if (input.length()>lengthName_) {
249    return 0;
250  } else {
251    unsigned int i;
252    for (i=0;i<input.length();i++) {
253      if (tolower(name_[i])!=tolower(input[i])) 
254        break;
255    }
256    if (i<input.length()) {
257      return 0;
258    } else if (i>=lengthMatch_) {
259      return 1;
260    } else {
261      // matched but too short
262      return 2;
263    }
264  }
265}
266// Returns name which could match
267std::string
268CbcOrClpParam::matchName (  ) const
269{ 
270  if (lengthMatch_==lengthName_) 
271    return name_;
272  else
273    return name_.substr(0,lengthMatch_)+"("+name_.substr(lengthMatch_)+")";
274}
275
276// Returns parameter option which matches (-1 if none)
277int 
278CbcOrClpParam::parameterOption ( std::string check ) const
279{
280  int numberItems = definedKeyWords_.size();
281  if (!numberItems) {
282    return -1;
283  } else {
284    int whichItem=0;
285    unsigned int it;
286    for (it=0;it<definedKeyWords_.size();it++) {
287      std::string thisOne = definedKeyWords_[it];
288      std::string::size_type  shriekPos = thisOne.find('!');
289      unsigned int length1 = thisOne.length();
290      unsigned int length2 = length1;
291      if ( shriekPos!=std::string::npos ) {
292        //contains '!'
293        length2 = shriekPos;
294        thisOne = thisOne.substr(0,shriekPos)+
295          thisOne.substr(shriekPos+1);
296        length1 = thisOne.length();
297      }
298      if (check.length()<=length1&&length2<=check.length()) {
299        unsigned int i;
300        for (i=0;i<check.length();i++) {
301          if (tolower(thisOne[i])!=tolower(check[i])) 
302            break;
303        }
304        if (i<check.length()) {
305          whichItem++;
306        } else if (i>=length2) {
307          break;
308        } 
309      } else {
310        whichItem++;
311      }
312    }
313    if (whichItem<numberItems)
314      return whichItem;
315    else
316      return -1;
317  }
318}
319// Prints parameter options
320void 
321CbcOrClpParam::printOptions (  ) const
322{
323  std::cout<<"<Possible options for "<<name_<<" are:";
324  unsigned int it;
325  for (it=0;it<definedKeyWords_.size();it++) {
326    std::string thisOne = definedKeyWords_[it];
327    std::string::size_type  shriekPos = thisOne.find('!');
328    if ( shriekPos!=std::string::npos ) {
329      //contains '!'
330      thisOne = thisOne.substr(0,shriekPos)+
331        "("+thisOne.substr(shriekPos+1)+")";
332    }
333    std::cout<<" "<<thisOne;
334  }
335  assert (currentKeyWord_>=0&&currentKeyWord_<(int)definedKeyWords_.size());
336  std::string current = definedKeyWords_[currentKeyWord_];
337  std::string::size_type  shriekPos = current.find('!');
338  if ( shriekPos!=std::string::npos ) {
339    //contains '!'
340    current = current.substr(0,shriekPos)+
341      "("+current.substr(shriekPos+1)+")";
342  }
343  std::cout<<";\n\tcurrent  "<<current<<">"<<std::endl;
344}
345// Print action and string
346void 
347CbcOrClpParam::printString() const
348{
349  if (name_=="directory")
350    std::cout<<"Current working directory is "<<stringValue_<<std::endl;
351  else if (name_.substr(0,6)=="printM")
352    std::cout<<"Current value of printMask is "<<stringValue_<<std::endl;
353  else
354    std::cout<<"Current default (if $ as parameter) for "<<name_
355             <<" is "<<stringValue_<<std::endl;
356}
357void CoinReadPrintit(const char * input)
358{
359  int length =strlen(input);
360  char temp[101];
361  int i;
362  int n=0;
363  for (i=0;i<length;i++) {
364    if (input[i]=='\n') {
365      temp[n]='\0';
366      std::cout<<temp<<std::endl;
367      n=0;
368    } else if (n>=65&&input[i]==' ') {
369      temp[n]='\0';
370      std::cout<<temp<<std::endl;
371      n=0;
372    } else if (n||input[i]!=' ') {
373      temp[n++]=input[i];
374    }
375  }
376  if (n) {
377    temp[n]='\0';
378    std::cout<<temp<<std::endl;
379  }
380}
381// Print Long help
382void 
383CbcOrClpParam::printLongHelp() const
384{
385  if (type_>=1&&type_<400) {
386    CoinReadPrintit(longHelp_.c_str());
387    if (type_<SOLVERLOGLEVEL) {
388      printf("<Range of values is %g to %g;\n\tcurrent %g>\n",lowerDoubleValue_,upperDoubleValue_, doubleValue_);
389      assert (upperDoubleValue_>lowerDoubleValue_);
390    } else if (type_<DIRECTION) {
391      printf("<Range of values is %d to %d;\n\tcurrent %d>\n",lowerIntValue_,upperIntValue_,intValue_);
392      assert (upperIntValue_>lowerIntValue_);
393    } else if (type_<DIRECTORY) {
394      printOptions();
395    }
396  }
397}
398#ifdef COIN_HAS_CBC
399int
400CbcOrClpParam::setDoubleParameter (OsiSolverInterface * model,double value) 
401{
402  if (value<lowerDoubleValue_||value>upperDoubleValue_) {
403    std::cout<<value<<" was provided for "<<name_<<
404      " - valid range is "<<lowerDoubleValue_<<" to "<<
405      upperDoubleValue_<<std::endl;
406    return 1;
407  } else {
408    double oldValue=doubleValue_;
409    doubleValue_=value;
410    switch(type_) {
411    case DUALTOLERANCE:
412      model->getDblParam(OsiDualTolerance,oldValue);
413      model->setDblParam(OsiDualTolerance,value);
414      break;
415    case PRIMALTOLERANCE:
416      model->getDblParam(OsiPrimalTolerance,oldValue);
417      model->setDblParam(OsiPrimalTolerance,value);
418      break;
419    default:
420      break;
421    }
422    if (doPrinting)
423      std::cout<<name_<<" was changed from "<<oldValue<<" to "
424               <<value<<std::endl;
425    return 0;
426  }
427}
428#endif
429#ifdef COIN_HAS_CLP
430int
431CbcOrClpParam::setDoubleParameter (ClpSimplex * model,double value) 
432{
433  double oldValue = doubleValue_;
434  if (value<lowerDoubleValue_||value>upperDoubleValue_) {
435    std::cout<<value<<" was provided for "<<name_<<
436      " - valid range is "<<lowerDoubleValue_<<" to "<<
437      upperDoubleValue_<<std::endl;
438    return 1;
439  } else {
440    if (doPrinting)
441      std::cout<<name_<<" was changed from "<<oldValue<<" to "
442               <<value<<std::endl;
443    doubleValue_=value;
444    switch(type_) {
445#ifndef COIN_HAS_CBC
446    case DUALTOLERANCE:
447      model->setDualTolerance(value);
448      break;
449    case PRIMALTOLERANCE:
450      model->setPrimalTolerance(value);
451      break;
452#endif
453    case DUALBOUND:
454      model->setDualBound(value);
455      break;
456    case PRIMALWEIGHT:
457      model->setInfeasibilityCost(value);
458      break;
459#ifndef COIN_HAS_CBC
460    case TIMELIMIT:
461      model->setMaximumSeconds(value);
462      break;
463#endif
464    case OBJSCALE:
465      model->setObjectiveScale(value);
466      break;
467    case RHSSCALE:
468      model->setRhsScale(value);
469      break;
470    case PRESOLVETOLERANCE:
471      model->setDblParam(ClpPresolveTolerance,value);
472      break;
473    default:
474      break;
475    }
476    return 0;
477  }
478}
479double 
480CbcOrClpParam::doubleParameter (ClpSimplex * model) const
481{
482  double value;
483  switch(type_) {
484#ifndef COIN_HAS_CBC
485  case DUALTOLERANCE:
486    value=model->dualTolerance();
487    break;
488  case PRIMALTOLERANCE:
489    value=model->primalTolerance();
490    break;
491#endif
492  case DUALBOUND:
493    value=model->dualBound();
494    break;
495  case PRIMALWEIGHT:
496    value=model->infeasibilityCost();
497    break;
498#ifndef COIN_HAS_CBC
499  case TIMELIMIT:
500    value=model->maximumSeconds();
501    break;
502#endif
503  case OBJSCALE:
504    value=model->objectiveScale();
505    break;
506  case RHSSCALE:
507    value=model->rhsScale();
508    break;
509  default:
510    value=doubleValue_;
511    break;
512  }
513  return value;
514}
515int 
516CbcOrClpParam::setIntParameter (ClpSimplex * model,int value) 
517{
518  int oldValue = intValue_;
519  if (value<lowerIntValue_||value>upperIntValue_) {
520    std::cout<<value<<" was provided for "<<name_<<
521      " - valid range is "<<lowerIntValue_<<" to "<<
522      upperIntValue_<<std::endl;
523    return 1;
524  } else {
525    intValue_=value;
526    if (doPrinting)
527      std::cout<<name_<<" was changed from "<<oldValue<<" to "
528               <<value<<std::endl;
529    switch(type_) {
530    case SOLVERLOGLEVEL:
531      model->setLogLevel(value);
532      if (value>2)
533        model->factorization()->messageLevel(8);
534      else
535        model->factorization()->messageLevel(0);
536      break;
537    case MAXFACTOR:
538      model->factorization()->maximumPivots(value);
539      break;
540    case PERTVALUE:
541      model->setPerturbation(value);
542      break;
543    case MAXITERATION:
544      model->setMaximumIterations(value);
545      break;
546    case SPECIALOPTIONS:
547      model->setSpecialOptions(value);
548#ifdef COIN_HAS_CBC
549    case THREADS:
550      model->setNumberThreads(value);
551      break;
552#endif
553    default:
554      break;
555    }
556    return 0;
557  }
558}
559int 
560CbcOrClpParam::intParameter (ClpSimplex * model) const
561{
562  int value;
563  switch(type_) {
564#ifndef COIN_HAS_CBC
565  case SOLVERLOGLEVEL:
566    value=model->logLevel();
567    break;
568#endif
569  case MAXFACTOR:
570    value=model->factorization()->maximumPivots();
571    break;
572    break;
573  case PERTVALUE:
574    value=model->perturbation();
575    break;
576  case MAXITERATION:
577    value=model->maximumIterations();
578    break;
579  case SPECIALOPTIONS:
580    value=model->specialOptions();
581    break;
582#ifndef COIN_HAS_CBC
583  case THREADS:
584    value = model->numberThreads();
585#endif
586  default:
587    value=intValue_;
588    break;
589  }
590  return value;
591}
592#endif
593int
594CbcOrClpParam::checkDoubleParameter (double value) const
595{
596  if (value<lowerDoubleValue_||value>upperDoubleValue_) {
597    std::cout<<value<<" was provided for "<<name_<<
598      " - valid range is "<<lowerDoubleValue_<<" to "<<
599      upperDoubleValue_<<std::endl;
600    return 1;
601  } else {
602    return 0;
603  }
604}
605#ifdef COIN_HAS_CBC
606double 
607CbcOrClpParam::doubleParameter (OsiSolverInterface * model) const
608{
609  double value=0.0;
610  switch(type_) {
611  case DUALTOLERANCE:
612    assert(model->getDblParam(OsiDualTolerance,value));
613    break;
614  case PRIMALTOLERANCE:
615    assert(model->getDblParam(OsiPrimalTolerance,value));
616    break;
617  default:
618    return doubleValue_;
619    break;
620  }
621  return value;
622}
623int 
624CbcOrClpParam::setIntParameter (OsiSolverInterface * model,int value) 
625{
626  if (value<lowerIntValue_||value>upperIntValue_) {
627    std::cout<<value<<" was provided for "<<name_<<
628      " - valid range is "<<lowerIntValue_<<" to "<<
629      upperIntValue_<<std::endl;
630    return 1;
631  } else {
632    int oldValue=intValue_;
633    intValue_=oldValue;
634    switch(type_) {
635    case SOLVERLOGLEVEL:
636      model->messageHandler()->setLogLevel(value);
637      break;
638    default:
639      break;
640    }
641    if (doPrinting)
642      std::cout<<name_<<" was changed from "<<oldValue<<" to "
643               <<value<<std::endl;
644    return 0;
645  }
646}
647int 
648CbcOrClpParam::intParameter (OsiSolverInterface * model) const
649{
650  int value=0;
651  switch(type_) {
652  case SOLVERLOGLEVEL:
653    value=model->messageHandler()->logLevel();
654    break;
655  default:
656    value=intValue_;
657    break;
658  }
659  return value;
660}
661int
662CbcOrClpParam::setDoubleParameter (CbcModel &model,double value) 
663{
664  if (value<lowerDoubleValue_||value>upperDoubleValue_) {
665    std::cout<<value<<" was provided for "<<name_<<
666      " - valid range is "<<lowerDoubleValue_<<" to "<<
667      upperDoubleValue_<<std::endl;
668    return 1;
669  } else {
670    double oldValue=doubleValue_;
671    doubleValue_ = value;
672    switch(type_) {
673    case INFEASIBILITYWEIGHT:
674      oldValue=model.getDblParam(CbcModel::CbcInfeasibilityWeight);
675      model.setDblParam(CbcModel::CbcInfeasibilityWeight,value);
676      break;
677    case INTEGERTOLERANCE:
678      oldValue=model.getDblParam(CbcModel::CbcIntegerTolerance);
679      model.setDblParam(CbcModel::CbcIntegerTolerance,value);
680      break;
681    case INCREMENT:
682      oldValue=model.getDblParam(CbcModel::CbcCutoffIncrement);
683      model.setDblParam(CbcModel::CbcCutoffIncrement,value);
684    case ALLOWABLEGAP:
685      oldValue=model.getDblParam(CbcModel::CbcAllowableGap);
686      model.setDblParam(CbcModel::CbcAllowableGap,value);
687      break;
688    case CUTOFF:
689      oldValue=model.getCutoff();
690      model.setCutoff(value);
691      break;
692    case TIMELIMIT_BAB:
693      oldValue = model.getDblParam(CbcModel::CbcMaximumSeconds) ;
694      {
695        //OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (model.solver());
696        //ClpSimplex * lpSolver = clpSolver->getModelPtr();
697        //lpSolver->setMaximumSeconds(value);
698        model.setDblParam(CbcModel::CbcMaximumSeconds,value) ;
699      }
700      break ;
701    case DUALTOLERANCE:
702    case PRIMALTOLERANCE:
703      setDoubleParameter(model.solver(),value);
704      return 0; // to avoid message
705    default:
706      break;
707    }
708    if (doPrinting)
709      std::cout<<name_<<" was changed from "<<oldValue<<" to "
710               <<value<<std::endl;
711    return 0;
712  }
713}
714double 
715CbcOrClpParam::doubleParameter (CbcModel &model) const
716{
717  double value;
718  switch(type_) {
719  case INFEASIBILITYWEIGHT:
720    value=model.getDblParam(CbcModel::CbcInfeasibilityWeight);
721    break;
722  case INTEGERTOLERANCE:
723    value=model.getDblParam(CbcModel::CbcIntegerTolerance);
724    break;
725  case INCREMENT:
726    value=model.getDblParam(CbcModel::CbcCutoffIncrement);
727  case ALLOWABLEGAP:
728    value=model.getDblParam(CbcModel::CbcAllowableGap);
729    break;
730  case CUTOFF:
731    value=model.getCutoff();
732    break;
733  case TIMELIMIT_BAB:
734    value = model.getDblParam(CbcModel::CbcMaximumSeconds) ;
735    break ;
736  case DUALTOLERANCE:
737  case PRIMALTOLERANCE:
738    value=doubleParameter(model.solver());
739    break;
740  default:
741    value = doubleValue_;
742    break;
743  }
744  return value;
745}
746int 
747CbcOrClpParam::setIntParameter (CbcModel &model,int value) 
748{
749  if (value<lowerIntValue_||value>upperIntValue_) {
750    std::cout<<value<<" was provided for "<<name_<<
751      " - valid range is "<<lowerIntValue_<<" to "<<
752      upperIntValue_<<std::endl;
753    return 1;
754  } else {
755    int oldValue=intValue_;
756    intValue_ = value;
757    switch(type_) {
758    case LOGLEVEL:
759      oldValue = model.messageHandler()->logLevel();
760      model.messageHandler()->setLogLevel(CoinAbs(value));
761      break;
762    case SOLVERLOGLEVEL:
763      oldValue = model.solver()->messageHandler()->logLevel();
764      model.solver()->messageHandler()->setLogLevel(value);
765      break;
766    case MAXNODES:
767      oldValue=model.getIntParam(CbcModel::CbcMaxNumNode);
768      model.setIntParam(CbcModel::CbcMaxNumNode,value);
769      break;
770    case MAXSOLS:
771      oldValue=model.getIntParam(CbcModel::CbcMaxNumSol);
772      model.setIntParam(CbcModel::CbcMaxNumSol,value);
773      break;
774    case STRONGBRANCHING:
775      oldValue=model.numberStrong();
776      model.setNumberStrong(value);
777      break;
778    case NUMBERBEFORE:
779      oldValue=model.numberBeforeTrust();
780      model.setNumberBeforeTrust(value);
781      break;
782    case NUMBERANALYZE:
783      oldValue=model.numberAnalyzeIterations();
784      model.setNumberAnalyzeIterations(value);
785      break;
786    case NUMBERMINI:
787      oldValue=model.sizeMiniTree();
788      model.setSizeMiniTree(value);
789      break;
790    case CUTPASSINTREE:
791      oldValue=model.getMaximumCutPasses();
792      model.setMaximumCutPasses(value);
793      break;
794    case CUTPASS:
795      oldValue=model.getMaximumCutPassesAtRoot();
796      model.setMaximumCutPassesAtRoot(value);
797      break;
798#ifdef COIN_HAS_CBC
799#ifdef CBC_THREAD
800    case THREADS:
801      oldValue=model.getNumberThreads();
802      model.setNumberThreads(value);
803      break;
804#endif
805#endif
806    default:
807      break;
808    }
809    if (doPrinting)
810      std::cout<<name_<<" was changed from "<<oldValue<<" to "
811               <<value<<std::endl;
812    return 0;
813  }
814}
815int 
816CbcOrClpParam::intParameter (CbcModel &model) const
817{
818  int value;
819  switch(type_) {
820  case LOGLEVEL:
821    value = model.messageHandler()->logLevel();
822      break;
823  case SOLVERLOGLEVEL:
824    value = model.solver()->messageHandler()->logLevel();
825      break;
826  case MAXNODES:
827    value = model.getIntParam(CbcModel::CbcMaxNumNode);
828    break;
829  case MAXSOLS:
830    value = model.getIntParam(CbcModel::CbcMaxNumSol);
831    break;
832  case STRONGBRANCHING:
833    value=model.numberStrong();
834    break;
835  case NUMBERBEFORE:
836    value=model.numberBeforeTrust();
837    break;
838  case NUMBERANALYZE:
839    value=model.numberAnalyzeIterations();
840    break;
841  case NUMBERMINI:
842    value=model.sizeMiniTree();
843    break;
844  case CUTPASSINTREE:
845    value=model.getMaximumCutPasses();
846    break;
847  case CUTPASS:
848    value=model.getMaximumCutPassesAtRoot();
849    break;
850#ifdef COIN_HAS_CBC
851#ifdef CBC_THREAD
852  case THREADS:
853    value = model.getNumberThreads();
854#endif
855#endif
856  default:
857    value=intValue_;
858    break;
859  }
860  return value;
861}
862#endif
863// Sets current parameter option using string
864void 
865CbcOrClpParam::setCurrentOption ( const std::string value )
866{
867  int action = parameterOption(value);
868  if (action>=0)
869    currentKeyWord_=action;
870}
871// Sets current parameter option
872void 
873CbcOrClpParam::setCurrentOption ( int value , bool printIt)
874{
875  if (printIt&&value!=currentKeyWord_)
876    std::cout<<"Option for "<<name_<<" changed from "
877             <<definedKeyWords_[currentKeyWord_]<<" to "
878             <<definedKeyWords_[value]<<std::endl;
879
880    currentKeyWord_=value;
881}
882void 
883CbcOrClpParam::setIntValue ( int value )
884{ 
885  if (value<lowerIntValue_||value>upperIntValue_) {
886    std::cout<<value<<" was provided for "<<name_<<
887      " - valid range is "<<lowerIntValue_<<" to "<<
888      upperIntValue_<<std::endl;
889  } else {
890    intValue_=value;
891  }
892}
893void 
894CbcOrClpParam::setDoubleValue ( double value )
895{ 
896  if (value<lowerDoubleValue_||value>upperDoubleValue_) {
897    std::cout<<value<<" was provided for "<<name_<<
898      " - valid range is "<<lowerDoubleValue_<<" to "<<
899      upperDoubleValue_<<std::endl;
900  } else {
901    doubleValue_=value;
902  }
903}
904void 
905CbcOrClpParam::setStringValue ( std::string value )
906{ 
907  stringValue_=value;
908}
909static char line[1000];
910static char * where=NULL;
911extern int CbcOrClpRead_mode;
912extern FILE * CbcOrClpReadCommand;
913// Simple read stuff
914std::string
915CoinReadNextField()
916{
917  std::string field;
918  if (!where) {
919    // need new line
920#ifdef COIN_HAS_READLINE     
921    if (CbcOrClpReadCommand==stdin) {
922      // Get a line from the user.
923      where = readline (coin_prompt);
924     
925      // If the line has any text in it, save it on the history.
926      if (where) {
927        if ( *where)
928          add_history (where);
929        strcpy(line,where);
930        free(where);
931      }
932    } else {
933      where = fgets(line,1000,CbcOrClpReadCommand);
934    }
935#else
936    if (CbcOrClpReadCommand==stdin) {
937      fprintf(stdout,coin_prompt);
938      fflush(stdout);
939    }
940    where = fgets(line,1000,CbcOrClpReadCommand);
941#endif
942    if (!where)
943      return field; // EOF
944    where = line;
945    // clean image
946    char * lastNonBlank = line-1;
947    while ( *where != '\0' ) {
948      if ( *where != '\t' && *where < ' ' ) {
949        break;
950      } else if ( *where != '\t' && *where != ' ') {
951        lastNonBlank = where;
952      }
953      where++;
954    }
955    where=line;
956    *(lastNonBlank+1)='\0';
957  }
958  // munch white space
959  while(*where==' '||*where=='\t')
960    where++;
961  char * saveWhere = where;
962  while (*where!=' '&&*where!='\t'&&*where!='\0')
963    where++;
964  if (where!=saveWhere) {
965    char save = *where;
966    *where='\0';
967    //convert to string
968    field=saveWhere;
969    *where=save;
970  } else {
971    where=NULL;
972    field="EOL";
973  }
974  return field;
975}
976
977std::string
978CoinReadGetCommand(int argc, const char *argv[])
979{
980  std::string field="EOL";
981  // say no =
982  afterEquals="";
983  while (field=="EOL") {
984    if (CbcOrClpRead_mode>0) {
985      if (CbcOrClpRead_mode<argc) {
986        field = argv[CbcOrClpRead_mode++];
987        if (field=="-") {
988          std::cout<<"Switching to line mode"<<std::endl;
989          CbcOrClpRead_mode=-1;
990          field=CoinReadNextField();
991        } else if (field[0]!='-') {
992          if (CbcOrClpRead_mode!=2) {
993            // now allow std::cout<<"skipping non-command "<<field<<std::endl;
994            // field="EOL"; // skip
995          } else {
996            // special dispensation - taken as -import name
997            CbcOrClpRead_mode--;
998            field="import";
999          }
1000        } else {
1001          if (field!="--") {
1002            // take off -
1003            field = field.substr(1);
1004          } else {
1005            // special dispensation - taken as -import --
1006            CbcOrClpRead_mode--;
1007            field="import";
1008          }
1009        }
1010      } else {
1011        field="";
1012      }
1013    } else {
1014      field=CoinReadNextField();
1015    }
1016  }
1017  // if = then modify and save
1018  std::string::size_type found = field.find('=');
1019  if (found!=std::string::npos) {
1020    afterEquals = field.substr(found+1);
1021    field = field.substr(0,found);
1022  }
1023  //std::cout<<field<<std::endl;
1024  return field;
1025}
1026std::string
1027CoinReadGetString(int argc, const char *argv[])
1028{
1029  std::string field="EOL";
1030  if (afterEquals=="") {
1031    if (CbcOrClpRead_mode>0) {
1032      if (CbcOrClpRead_mode<argc) {
1033        if (argv[CbcOrClpRead_mode][0]!='-') { 
1034          field = argv[CbcOrClpRead_mode++];
1035        } else if (!strcmp(argv[CbcOrClpRead_mode],"--")) {
1036          field = argv[CbcOrClpRead_mode++];
1037          // -- means import from stdin
1038          field = "-";
1039        }
1040      }
1041    } else {
1042      field=CoinReadNextField();
1043    }
1044  } else {
1045    field=afterEquals;
1046    afterEquals = "";
1047  }
1048  //std::cout<<field<<std::endl;
1049  return field;
1050}
1051// valid 0 - okay, 1 bad, 2 not there
1052int
1053CoinReadGetIntField(int argc, const char *argv[],int * valid)
1054{
1055  std::string field="EOL";
1056  if (afterEquals=="") {
1057    if (CbcOrClpRead_mode>0) {
1058      if (CbcOrClpRead_mode<argc) {
1059        // may be negative value so do not check for -
1060        field = argv[CbcOrClpRead_mode++];
1061      }
1062    } else {
1063      field=CoinReadNextField();
1064    }
1065  } else {
1066    field=afterEquals;
1067    afterEquals = "";
1068  }
1069  int value=0;
1070  //std::cout<<field<<std::endl;
1071  if (field!="EOL") {
1072    // how do I check valid
1073    value =  atoi(field.c_str());
1074    *valid=0;
1075  } else {
1076    *valid=2;
1077  }
1078  return value;
1079}
1080double
1081CoinReadGetDoubleField(int argc, const char *argv[],int * valid)
1082{
1083  std::string field="EOL";
1084  if (afterEquals=="") {
1085    if (CbcOrClpRead_mode>0) {
1086      if (CbcOrClpRead_mode<argc) {
1087        // may be negative value so do not check for -
1088        field = argv[CbcOrClpRead_mode++];
1089      }
1090    } else {
1091      field=CoinReadNextField();
1092    }
1093  } else {
1094    field=afterEquals;
1095    afterEquals = "";
1096  }
1097  double value=0.0;
1098  //std::cout<<field<<std::endl;
1099  if (field!="EOL") {
1100    // how do I check valid
1101    value = atof(field.c_str());
1102    *valid=0;
1103  } else {
1104    *valid=2;
1105  }
1106  return value;
1107}
1108/*
1109  Subroutine to establish the cbc parameter array. See the description of
1110  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
1111*/
1112void 
1113establishParams (int &numberParameters, CbcOrClpParam *const parameters)
1114{
1115  numberParameters=0;
1116  parameters[numberParameters++]=
1117    CbcOrClpParam("?","For help",GENERALQUERY,7,false);
1118  parameters[numberParameters++]=
1119    CbcOrClpParam("???","For help",FULLGENERALQUERY,7,false);
1120  parameters[numberParameters++]=
1121    CbcOrClpParam("-","From stdin",
1122                  STDIN,3,false);
1123#ifdef COIN_HAS_CBC
1124    parameters[numberParameters++]=
1125      CbcOrClpParam("allow!ableGap","Stop when gap between best possible and \
1126best less than this",
1127              0.0,1.0e20,ALLOWABLEGAP);
1128  parameters[numberParameters-1].setDoubleValue(0.0);
1129  parameters[numberParameters-1].setLonghelp
1130    (
1131     "If the gap between best solution and best possible solution is less than this \
1132then the search will be terminated.  Also see ratioGap."
1133     ); 
1134#endif
1135#ifdef COIN_HAS_CLP
1136  parameters[numberParameters++]=
1137    CbcOrClpParam("allS!lack","Set basis back to all slack and reset solution",
1138                  ALLSLACK,3);
1139  parameters[numberParameters-1].setLonghelp
1140    (
1141     "Mainly useful for tuning purposes.  Normally the first dual or primal will be using an all slack \
1142basis anyway."
1143     ); 
1144  parameters[numberParameters++]=
1145    CbcOrClpParam("auto!Scale","Whether to scale objective, rhs and bounds of problem if they look odd",
1146                  "off",AUTOSCALE,7,false);
1147  parameters[numberParameters-1].append("on");
1148  parameters[numberParameters-1].setLonghelp
1149    (
1150     "If you think you may get odd objective values or large equality rows etc then\
1151 it may be worth setting this true.  It is still experimental and you may prefer\
1152 to use objective!Scale and rhs!Scale"
1153     ); 
1154  parameters[numberParameters++]=
1155    CbcOrClpParam("barr!ier","Solve using primal dual predictor corrector algorithm",
1156                  BARRIER);
1157  parameters[numberParameters-1].setLonghelp
1158    (
1159     "This command solves the current model using the  primal dual predictor \
1160corrector algorithm.  You will probably want to link in and choose a better \
1161ordering and factorization than the default ones provided.  It will also solve models \
1162with quadratic objectives."
1163     
1164     ); 
1165  parameters[numberParameters++]=
1166    CbcOrClpParam("basisI!n","Import basis from bas file",
1167                  BASISIN,3);
1168  parameters[numberParameters-1].setLonghelp
1169    (
1170     "This will read an MPS format basis file from the given file name.  It will use the default\
1171 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
1172 is initialized to '', i.e. it must be set.  If you have libz then it can read compressed\
1173 files 'xxxxxxxx.gz'.."
1174     ); 
1175  parameters[numberParameters++]=
1176    CbcOrClpParam("basisO!ut","Export basis as bas file",
1177                  BASISOUT);
1178  parameters[numberParameters-1].setLonghelp
1179    (
1180     "This will write an MPS format basis file to the given file name.  It will use the default\
1181 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
1182 is initialized to 'default.bas'."
1183     ); 
1184  parameters[numberParameters++]=
1185    CbcOrClpParam("biasLU","Whether factorization biased towards U",
1186                  "UU",BIASLU,2,false);
1187  parameters[numberParameters-1].append("UX");
1188  parameters[numberParameters-1].append("LX");
1189  parameters[numberParameters-1].append("LL");
1190  parameters[numberParameters-1].setCurrentOption("LX");
1191#endif
1192#ifdef COIN_HAS_CBC
1193  parameters[numberParameters++]=
1194    CbcOrClpParam("branch!AndCut","Do Branch and Cut",
1195                  BAB);
1196  parameters[numberParameters-1].setLonghelp
1197    (
1198     "This does branch and cut.  There are many parameters which can affect the performance.  \
1199First just try with default settings and look carefully at the log file.  Did cuts help?  Did they take too long?  \
1200Look at output to see which cuts were effective and then do some tuning.  You will see that the \
1201options for cuts are off, on, root and ifmove, forceon.  Off is \
1202obvious, on means that this cut generator will be tried in the branch and cut tree (you can fine tune using \
1203'depth').  Root means just at the root node while 'ifmove' means that cuts will be used in the tree if they \
1204look as if they are doing some good and moving the objective value.  Forceon is same as on but forces code to use \
1205cut generator at every node.  For probing forceonbut just does fixing probing in tree - not strengthening etc.  \
1206If pre-processing reduced the size of the \
1207problem or strengthened many coefficients then it is probably wise to leave it on.  Switch off heuristics \
1208which did not provide solutions.  The other major area to look at is the search.  Hopefully good solutions \
1209were obtained fairly early in the search so the important point is to select the best variable to branch on.  \
1210See whether strong branching did a good job - or did it just take a lot of iterations.  Adjust the strongBranching \
1211and trustPseudoCosts parameters."
1212     ); 
1213#endif
1214  parameters[numberParameters++]=
1215    CbcOrClpParam("bscale","Whether to scale in barrier",
1216                  "off",BARRIERSCALE,7,false);
1217  parameters[numberParameters-1].append("on");
1218  parameters[numberParameters++]=
1219    CbcOrClpParam("chol!esky","Which cholesky algorithm",
1220                  "native",CHOLESKY,7);
1221  parameters[numberParameters-1].append("dense");
1222  //#ifdef FOREIGN_BARRIER
1223#ifdef WSSMP_BARRIER
1224  parameters[numberParameters-1].append("fudge!Long");
1225  parameters[numberParameters-1].append("wssmp");
1226#define REAL_BARRIER
1227#else
1228  parameters[numberParameters-1].append("fudge!Long_dummy");
1229  parameters[numberParameters-1].append("wssmp_dummy");
1230#endif
1231#ifdef UFL_BARRIER
1232  parameters[numberParameters-1].append("Uni!versityOfFlorida");
1233#define REAL_BARRIER
1234#else
1235  parameters[numberParameters-1].append("Uni!versityOfFlorida_dummy");   
1236#endif
1237#ifdef TAUCS_BARRIER
1238  parameters[numberParameters-1].append("Taucs");
1239#define REAL_BARRIER
1240#else
1241  parameters[numberParameters-1].append("Taucs_dummy");
1242#endif
1243  parameters[numberParameters-1].setLonghelp
1244    (
1245     "For a barrier code to be effective it needs a good Cholesky ordering and factorization.  \
1246You will need to link in one from another source.  See Makefile.locations for some \
1247possibilities."
1248     ); 
1249  //#endif
1250#ifdef COIN_HAS_CBC
1251  parameters[numberParameters++]=
1252    CbcOrClpParam("clique!Cuts","Whether to use Clique cuts",
1253                  "off",CLIQUECUTS);
1254  parameters[numberParameters-1].append("on");
1255  parameters[numberParameters-1].append("root");
1256  parameters[numberParameters-1].append("ifmove");
1257  parameters[numberParameters-1].append("forceOn");
1258  parameters[numberParameters-1].setLonghelp
1259    (
1260     "This switches on clique cuts (either at root or in entire tree) \
1261See branchAndCut for information on options."
1262     ); 
1263  parameters[numberParameters++]=
1264    CbcOrClpParam("combine!Solutions","Whether to use combine solution heuristic",
1265                  "off",COMBINE);
1266  parameters[numberParameters-1].append("on");
1267  parameters[numberParameters-1].setLonghelp
1268    (
1269     "This switches on a heuristic which does branch and cut on the problem given by just \
1270using variables which have appeared in one or more solutions. \
1271It obviously only tries after two or more solutions."
1272     ); 
1273  parameters[numberParameters++]=
1274    CbcOrClpParam("cost!Strategy","How to use costs as priorities",
1275                  "off",COSTSTRATEGY);
1276  parameters[numberParameters-1].append("pri!orities");
1277  parameters[numberParameters-1].append("column!Order?");
1278  parameters[numberParameters-1].append("01f!irst?");
1279  parameters[numberParameters-1].append("01l!ast?");
1280  parameters[numberParameters-1].append("length!?");
1281  parameters[numberParameters-1].setLonghelp
1282    (
1283     "This orders the variables in order of their absolute costs - with largest cost ones being branched on \
1284first.  This primitive strategy can be surprsingly effective.  The column order\
1285 option is obviously not on costs but easy to code here."
1286     ); 
1287#endif
1288  parameters[numberParameters++]=
1289    CbcOrClpParam("cpp!Generate","Generates C++ code",
1290                  -1,50000,CPP);
1291  parameters[numberParameters-1].setLonghelp
1292    (
1293     "Once you like what the stand-alone solver does then this allows \
1294you to generate user_driver.cpp which approximates the code.  \
12950 gives simplest driver, 1 generates saves and restores, 2 \
1296generates saves and restores even for variables at default value. \
12974 bit in cbc generates size dependent code rather than computed values."
1298     );
1299#ifdef COIN_HAS_CLP
1300  parameters[numberParameters++]=
1301    CbcOrClpParam("crash","Whether to create basis for problem",
1302                  "off",CRASH);
1303  parameters[numberParameters-1].append("on");
1304  parameters[numberParameters-1].append("so!low_halim");
1305  parameters[numberParameters-1].append("ha!lim_solow(JJF mods)");
1306  //  parameters[numberParameters-1].append("4");
1307  //  parameters[numberParameters-1].append("5");
1308  parameters[numberParameters-1].setLonghelp
1309    (
1310     "If crash is set on and there is an all slack basis then Clp will flip or put structural\
1311 variables into basis with the aim of getting dual feasible.  On the whole dual seems to be\
1312 better without it and there alernative types of 'crash' for primal e.g. 'idiot' or 'sprint'. \
1313I have also added a variant due to Solow and Halim which is as on but just flip."); 
1314  parameters[numberParameters++]=
1315    CbcOrClpParam("cross!over","Whether to get a basic solution after barrier",
1316                  "on",CROSSOVER);
1317  parameters[numberParameters-1].append("off");
1318  parameters[numberParameters-1].append("maybe");
1319  parameters[numberParameters-1].append("presolve");
1320  parameters[numberParameters-1].setLonghelp
1321    (
1322     "Interior point algorithms do not obtain a basic solution (and \
1323the feasibility criterion is a bit suspect (JJF)).  This option will crossover \
1324to a basic solution suitable for ranging or branch and cut.  With the current state \
1325of quadratic it may be a good idea to switch off crossover for quadratic (and maybe \
1326presolve as well) - the option maybe does this."
1327     );
1328#endif
1329#ifdef COIN_HAS_CBC
1330  parameters[numberParameters++]=
1331    CbcOrClpParam("cutD!epth","Depth in tree at which to do cuts",
1332                  -1,999999,CUTDEPTH);
1333  parameters[numberParameters-1].setLonghelp
1334    (
1335     "Cut generators may be - off, on only at root, on if they look possible \
1336and on.  If they are done every node then that is that, but it may be worth doing them \
1337every so often.  The original method was every so many nodes but it is more logical \
1338to do it whenever depth in tree is a multiple of K.  This option does that and defaults \
1339to -1 (off)."
1340     );
1341  parameters[numberParameters-1].setIntValue(-1);
1342  parameters[numberParameters++]=
1343    CbcOrClpParam("cuto!ff","All solutions must be better than this",
1344                  -1.0e60,1.0e60,CUTOFF);
1345  parameters[numberParameters-1].setDoubleValue(1.0e50);
1346  parameters[numberParameters-1].setLonghelp
1347    (
1348     "All solutions must be better than this value (in a minimization sense).  \
1349This is also set by code whenever it obtains a solution and is set to value of \
1350objective for solution minus cutoff increment."
1351     );
1352  parameters[numberParameters++]=
1353    CbcOrClpParam("cuts!OnOff","Switches all cuts on or off",
1354                  "off",CUTSSTRATEGY);
1355  parameters[numberParameters-1].append("on");
1356  parameters[numberParameters-1].append("root");
1357  parameters[numberParameters-1].append("ifmove");
1358  parameters[numberParameters-1].append("forceOn");
1359  parameters[numberParameters-1].setLonghelp
1360    (
1361     "This can be used to switch on or off all cuts (apart from Reduce and Split).  Then you can do \
1362individual ones off or on \
1363See branchAndCut for information on options."
1364     ); 
1365  parameters[numberParameters++]=
1366    CbcOrClpParam("debug!In","read valid solution from file",
1367                  DEBUG,7,false);
1368  parameters[numberParameters-1].setLonghelp
1369    (
1370     "This will read a solution file from the given file name.  It will use the default\
1371 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
1372 is initialized to '', i.e. it must be set.\n\n\
1373If set to create it will create a file called debug.file  after search; if set \
1374to createAfterPre it will create one suitable for use after preprocessing.\n\n\
1375The idea is that if you suspect a bad cut generator and you did not use preprocessing \
1376you can do a good run with debug set to 'create' and then switch on the cuts you suspect and \
1377re-run with debug set to 'debug.file'  Similarly if you do use preprocessing but use \
1378createAfterPre.  The create case has same effect as saveSolution."
1379     ); 
1380#endif
1381#ifdef COIN_HAS_CBC
1382  parameters[numberParameters++]=
1383    CbcOrClpParam("dextra1","Extra double parameter 1",
1384                  -COIN_DBL_MAX,COIN_DBL_MAX,DEXTRA1,false);
1385  parameters[numberParameters-1].setDoubleValue(0.0);
1386  parameters[numberParameters++]=
1387    CbcOrClpParam("dextra2","Extra double parameter 2",
1388                  -COIN_DBL_MAX,COIN_DBL_MAX,DEXTRA2,false);
1389  parameters[numberParameters-1].setDoubleValue(0.0);
1390  parameters[numberParameters++]=
1391    CbcOrClpParam("dextra3","Extra double parameter 3",
1392                  -COIN_DBL_MAX,COIN_DBL_MAX,DEXTRA3,false);
1393  parameters[numberParameters-1].setDoubleValue(0.0);
1394  parameters[numberParameters++]=
1395    CbcOrClpParam("dextra4","Extra double parameter 4",
1396                  -COIN_DBL_MAX,COIN_DBL_MAX,DEXTRA4,false);
1397  parameters[numberParameters-1].setDoubleValue(0.0);
1398#endif
1399  parameters[numberParameters++]=
1400    CbcOrClpParam("direction","Minimize or Maximize",
1401                  "min!imize",DIRECTION);
1402  parameters[numberParameters-1].append("max!imize");
1403  parameters[numberParameters-1].append("zero");
1404  parameters[numberParameters-1].setLonghelp
1405    (
1406     "The default is minimize - use 'direction maximize' for maximization.\n\
1407You can also use the parameters 'maximize' or 'minimize'."
1408     ); 
1409  parameters[numberParameters++]=
1410    CbcOrClpParam("directory","Set Default directory for import etc.",
1411                  DIRECTORY);
1412  parameters[numberParameters-1].setLonghelp
1413    (
1414     "This sets the directory which import, export, saveModel, restoreModel etc will use.\
1415  It is initialized to './'"
1416     ); 
1417#ifdef COIN_HAS_CLP
1418  parameters[numberParameters++]=
1419    CbcOrClpParam("dualB!ound","Initially algorithm acts as if no \
1420gap between bounds exceeds this value",
1421                  1.0e-20,1.0e12,DUALBOUND);
1422  parameters[numberParameters-1].setLonghelp
1423    (
1424     "The dual algorithm in Clp is a single phase algorithm as opposed to a two phase\
1425 algorithm where you first get feasible then optimal.  If a problem has both upper and\
1426 lower bounds then it is trivial to get dual feasible by setting non basic variables\
1427 to correct bound.  If the gap between the upper and lower bounds of a variable is more\
1428 than the value of dualBound Clp introduces fake bounds so that it can make the problem\
1429 dual feasible.  This has the same effect as a composite objective function in the\
1430 primal algorithm.  Too high a value may mean more iterations, while too low a bound means\
1431 the code may go all the way and then have to increase the bounds.  OSL had a heuristic to\
1432 adjust bounds, maybe we need that here."
1433     );
1434  parameters[numberParameters++]=
1435    CbcOrClpParam("dualize","Solves dual reformulation",
1436                  0,2,DUALIZE,false);
1437  parameters[numberParameters-1].setLonghelp
1438    (
1439     "Don't even think about it."
1440     ); 
1441  parameters[numberParameters++]=
1442    CbcOrClpParam("dualP!ivot","Dual pivot choice algorithm",
1443                  "auto!matic",DUALPIVOT);
1444  parameters[numberParameters-1].append("dant!zig");
1445  parameters[numberParameters-1].append("partial");
1446  parameters[numberParameters-1].append("steep!est");
1447  parameters[numberParameters-1].setLonghelp
1448    (
1449     "Clp can use any pivot selection algorithm which the user codes as long as it\
1450 implements the features in the abstract pivot base class.  The Dantzig method is implemented\
1451 to show a simple method but its use is deprecated.  Steepest is the method of choice and there\
1452 are two variants which keep all weights updated but only scan a subset each iteration.\
1453 Partial switches this on while automatic decides at each iteration based on information\
1454 about the factorization."
1455     ); 
1456  parameters[numberParameters++]=
1457    CbcOrClpParam("dualS!implex","Do dual simplex algorithm",
1458                  DUALSIMPLEX);
1459  parameters[numberParameters-1].setLonghelp
1460    (
1461     "This command solves the current model using the dual steepest edge algorithm.\
1462The time and iterations may be affected by settings such as presolve, scaling, crash\
1463 and also by dual pivot method, fake bound on variables and dual and primal tolerances."
1464     );
1465#endif
1466  parameters[numberParameters++]=
1467    CbcOrClpParam("dualT!olerance","For an optimal solution \
1468no dual infeasibility may exceed this value",
1469                  1.0e-20,1.0e12,DUALTOLERANCE);
1470  parameters[numberParameters-1].setLonghelp
1471    (
1472     "Normally the default tolerance is fine, but you may want to increase it a\
1473 bit if a dual run seems to be having a hard time.  One method which can be faster is \
1474to use a large tolerance e.g. 1.0e-4 and dual and then clean up problem using primal and the \
1475correct tolerance (remembering to switch off presolve for this final short clean up phase)."
1476     ); 
1477#ifdef COIN_HAS_CLP
1478  parameters[numberParameters++]=
1479    CbcOrClpParam("either!Simplex","Do dual or primal simplex algorithm",
1480                  EITHERSIMPLEX);
1481  parameters[numberParameters-1].setLonghelp
1482    (
1483     "This command solves the current model using the dual or primal algorithm,\
1484 based on a dubious analysis of model."
1485     );
1486#endif
1487  parameters[numberParameters++]=
1488    CbcOrClpParam("end","Stops clp execution",
1489                  EXIT);
1490  parameters[numberParameters-1].setLonghelp
1491    (
1492     "This stops execution ; end, exit, quit and stop are synonyms"
1493     ); 
1494  parameters[numberParameters++]=
1495    CbcOrClpParam("error!sAllowed","Whether to allow import errors",
1496                  "off",ERRORSALLOWED,3);
1497  parameters[numberParameters-1].append("on");
1498  parameters[numberParameters-1].setLonghelp
1499    (
1500     "The default is not to use any model which had errors when reading the mps file.\
1501  Setting this to 'on' will allow all errors from which the code can recover\
1502 simply by ignoring the error.  There are some errors from which the code can not recover \
1503e.g. no ENDATA.  This has to be set before import i.e. -errorsAllowed on -import xxxxxx.mps."
1504     );
1505  parameters[numberParameters++]=
1506    CbcOrClpParam("exit","Stops clp execution",
1507                  EXIT);
1508  parameters[numberParameters-1].setLonghelp
1509    (
1510     "This stops the execution of Clp, end, exit, quit and stop are synonyms"
1511     ); 
1512  parameters[numberParameters++]=
1513    CbcOrClpParam("export","Export model as mps file",
1514                  EXPORT);
1515  parameters[numberParameters-1].setLonghelp
1516    (
1517     "This will write an MPS format file to the given file name.  It will use the default\
1518 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
1519 is initialized to 'default.mps'."
1520     ); 
1521#ifdef COIN_HAS_CBC
1522  parameters[numberParameters++]=
1523    CbcOrClpParam("extra1","Extra integer parameter 1",
1524                  -1,COIN_INT_MAX,EXTRA1,false);
1525  parameters[numberParameters-1].setIntValue(-1);
1526  parameters[numberParameters++]=
1527    CbcOrClpParam("extra2","Extra integer parameter 2",
1528                  -1,COIN_INT_MAX,EXTRA2,false);
1529  parameters[numberParameters-1].setIntValue(-1);
1530  parameters[numberParameters++]=
1531    CbcOrClpParam("extra3","Extra integer parameter 3",
1532                  -1,COIN_INT_MAX,EXTRA3,false);
1533  parameters[numberParameters-1].setIntValue(-1);
1534  parameters[numberParameters++]=
1535    CbcOrClpParam("extra4","Extra integer parameter 4",
1536                  -1,COIN_INT_MAX,EXTRA4,false);
1537  parameters[numberParameters-1].setIntValue(-1);
1538#endif
1539#ifdef COIN_HAS_CLP
1540  parameters[numberParameters++]=
1541    CbcOrClpParam("fakeB!ound","All bounds <= this value - DEBUG",
1542                  1.0,1.0e15,FAKEBOUND,false);
1543#ifdef COIN_HAS_CBC
1544    parameters[numberParameters++]=
1545      CbcOrClpParam("feas!ibilityPump","Whether to try Feasibility Pump",
1546                    "off",FPUMP);
1547    parameters[numberParameters-1].append("on");
1548  parameters[numberParameters-1].setLonghelp
1549    (
1550     "This switches on feasibility pump heuristic at root. This is due to Fischetti and Lodi \
1551and uses a sequence of Lps to try and get an integer feasible solution. \
1552Some fine tuning is available by passFeasibilityPump."
1553     ); 
1554  parameters[numberParameters++]=
1555    CbcOrClpParam("fix!OnDj","Try heuristic based on fixing variables with \
1556reduced costs greater than this",
1557                  -1.0e20,1.0e20,DJFIX,false);
1558  parameters[numberParameters-1].setLonghelp
1559    (
1560     "If this is set integer variables with reduced costs greater than this will be fixed \
1561before branch and bound - use with extreme caution!" 
1562     ); 
1563    parameters[numberParameters++]=
1564      CbcOrClpParam("flow!CoverCuts","Whether to use Flow Cover cuts",
1565                    "off",FLOWCUTS);
1566    parameters[numberParameters-1].append("on");
1567    parameters[numberParameters-1].append("root");
1568    parameters[numberParameters-1].append("ifmove");
1569    parameters[numberParameters-1].append("forceOn");
1570    parameters[numberParameters-1].setLonghelp
1571    (
1572     "This switches on flow cover cuts (either at root or in entire tree) \
1573See branchAndCut for information on options."
1574     ); 
1575    parameters[numberParameters++]=
1576      CbcOrClpParam("force!Solution","Whether to use given solution as crash for BAB",
1577                    "off",USESOLUTION);
1578    parameters[numberParameters-1].append("on");
1579  parameters[numberParameters-1].setLonghelp
1580    (
1581     "If on then tries to branch to solution given by AMPL or priorities file."
1582     ); 
1583#endif
1584  parameters[numberParameters++]=
1585    CbcOrClpParam("gamma!(Delta)","Whether to regularize barrier",
1586                  "off",GAMMA,7,false);
1587  parameters[numberParameters-1].append("on");
1588  parameters[numberParameters-1].append("gamma");
1589  parameters[numberParameters-1].append("delta");
1590  parameters[numberParameters-1].append("onstrong");
1591  parameters[numberParameters-1].append("gammastrong");
1592  parameters[numberParameters-1].append("deltastrong");
1593#endif
1594#ifdef COIN_HAS_CBC
1595  parameters[numberParameters++]=
1596    CbcOrClpParam("gomory!Cuts","Whether to use Gomory cuts",
1597                  "off",GOMORYCUTS);
1598  parameters[numberParameters-1].append("on");
1599  parameters[numberParameters-1].append("root");
1600  parameters[numberParameters-1].append("ifmove");
1601  parameters[numberParameters-1].append("forceOn");
1602  parameters[numberParameters-1].setLonghelp
1603    (
1604     "The original cuts - beware of imitations!  Having gone out of favor, they are now more \
1605fashionable as LP solvers are more robust and they interact well with other cuts.  They will almost always \
1606give cuts (although in this executable they are limited as to number of variables in cut).  \
1607However the cuts may be dense so it is worth experimenting. \
1608See branchAndCut for information on options."
1609     ); 
1610  parameters[numberParameters++]=
1611    CbcOrClpParam("greedy!Heuristic","Whether to use a greedy heuristic",
1612                  "off",GREEDY);
1613  parameters[numberParameters-1].append("on");
1614  parameters[numberParameters-1].append("root");
1615  parameters[numberParameters-1].setLonghelp
1616    (
1617     "Switches on a greedy heuristic which will try and obtain a solution.  It may just fix a \
1618percentage of variables and then try a small branch and cut run."
1619     ); 
1620  parameters[numberParameters++]=
1621    CbcOrClpParam("heur!isticsOnOff","Switches most heuristics on or off",
1622                  "off",HEURISTICSTRATEGY);
1623  parameters[numberParameters-1].append("on");
1624  parameters[numberParameters-1].setLonghelp
1625    (
1626     "This can be used to switch on or off all heuristics.  Then you can do \
1627individual ones off or on.  CbcTreeLocal is not included as it dramatically \
1628alters search."
1629     ); 
1630#endif
1631  parameters[numberParameters++]=
1632    CbcOrClpParam("help","Print out version, non-standard options and some help",
1633                  HELP,3);
1634  parameters[numberParameters-1].setLonghelp
1635    (
1636     "This prints out some help to get user started.  If you have printed this then \
1637you should be past that stage:-)"
1638     ); 
1639#ifdef COIN_HAS_CBC
1640  parameters[numberParameters++]=
1641    CbcOrClpParam("hot!StartMaxIts","Maximum iterations on hot start",
1642                  0,COIN_INT_MAX,MAXHOTITS,false);
1643#endif
1644#ifdef COIN_HAS_CLP
1645  parameters[numberParameters++]=
1646    CbcOrClpParam("idiot!Crash","Whether to try idiot crash",
1647                  -1,999999,IDIOT);
1648  parameters[numberParameters-1].setLonghelp
1649    (
1650     "This is a type of 'crash' which works well on some homogeneous problems.\
1651 It works best on problems with unit elements and rhs but will do something to any model.  It should only be\
1652 used before primal.  It can be set to -1 when the code decides for itself whether to use it,\
1653 0 to switch off or n > 0 to do n passes."
1654     ); 
1655#endif
1656  parameters[numberParameters++]=
1657    CbcOrClpParam("import","Import model from mps file",
1658                  IMPORT,3);
1659  parameters[numberParameters-1].setLonghelp
1660    (
1661     "This will read an MPS format file from the given file name.  It will use the default\
1662 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
1663 is initialized to '', i.e. it must be set.  If you have libgz then it can read compressed\
1664 files 'xxxxxxxx.gz'.."
1665     );
1666#ifdef COIN_HAS_CBC
1667  parameters[numberParameters++]=
1668    CbcOrClpParam("inc!rement","A valid solution must be at least this \
1669much better than last integer solution",
1670                  -1.0e20,1.0e20,INCREMENT);
1671  parameters[numberParameters-1].setLonghelp
1672    (
1673     "Whenever a solution is found the bound on solutions is set to solution (in a minimization\
1674sense) plus this.  If it is not set then the code will try and work one out e.g. if \
1675all objective coefficients are multiples of 0.01 and only integer variables have entries in \
1676objective then this can be set to 0.01.  Be careful if you set this negative!"
1677     ); 
1678  parameters[numberParameters++]=
1679    CbcOrClpParam("inf!easibilityWeight","Each integer infeasibility is expected \
1680to cost this much",
1681                  0.0,1.0e20,INFEASIBILITYWEIGHT);
1682  parameters[numberParameters-1].setLonghelp
1683    (
1684     "A primitive way of deciding which node to explore next.  Satisfying each integer infeasibility is \
1685expected to cost this much."
1686     ); 
1687  parameters[numberParameters++]=
1688    CbcOrClpParam("initialS!olve","Solve to continuous",
1689                  SOLVECONTINUOUS);
1690  parameters[numberParameters-1].setLonghelp
1691    (
1692     "This just solves the problem to continuous - without adding any cuts"
1693     ); 
1694  parameters[numberParameters++]=
1695    CbcOrClpParam("integerT!olerance","For an optimal solution \
1696no integer variable may be this away from an integer value",
1697              1.0e-20,0.5,INTEGERTOLERANCE);
1698  parameters[numberParameters-1].setLonghelp
1699    (
1700     "Beware of setting this smaller than the primal tolerance."
1701     ); 
1702#endif
1703#ifdef COIN_HAS_CLP
1704  parameters[numberParameters++]=
1705    CbcOrClpParam("keepN!ames","Whether to keep names from import",
1706                  "on",KEEPNAMES);
1707  parameters[numberParameters-1].append("off");
1708  parameters[numberParameters-1].setLonghelp
1709    (
1710     "It saves space to get rid of names so if you need to you can set this to off.  \
1711This needs to be set before the import of model - so -keepnames off -import xxxxx.mps."
1712     ); 
1713  parameters[numberParameters++]=
1714    CbcOrClpParam("KKT","Whether to use KKT factorization",
1715                  "off",KKT,7,false);
1716  parameters[numberParameters-1].append("on");
1717#endif
1718#ifdef COIN_HAS_CBC
1719  parameters[numberParameters++]=
1720    CbcOrClpParam("knapsack!Cuts","Whether to use Knapsack cuts",
1721                  "off",KNAPSACKCUTS);
1722  parameters[numberParameters-1].append("on");
1723  parameters[numberParameters-1].append("root");
1724  parameters[numberParameters-1].append("ifmove");
1725  parameters[numberParameters-1].append("forceOn");
1726  parameters[numberParameters-1].setLonghelp
1727    (
1728     "This switches on knapsack cuts (either at root or in entire tree) \
1729See branchAndCut for information on options."
1730     ); 
1731  parameters[numberParameters++]=
1732    CbcOrClpParam("lift!AndProjectCuts","Whether to use Lift and Project cuts",
1733                  "off",LANDPCUTS);
1734  parameters[numberParameters-1].append("on");
1735  parameters[numberParameters-1].append("root");
1736  parameters[numberParameters-1].append("ifmove");
1737  parameters[numberParameters-1].append("forceOn");
1738  parameters[numberParameters-1].setLonghelp
1739    (
1740     "Lift and project cuts - may be expensive to compute. \
1741See branchAndCut for information on options."
1742     ); 
1743  parameters[numberParameters++]=
1744    CbcOrClpParam("local!TreeSearch","Whether to use local treesearch",
1745                  "off",LOCALTREE);
1746  parameters[numberParameters-1].append("on");
1747  parameters[numberParameters-1].setLonghelp
1748    (
1749     "This switches on a local search algorithm when a solution is found.  This is from \
1750Fischetti and Lodi and is not really a heuristic although it can be used as one. \
1751When used from Coin solve it has limited functionality.  It is not switched on when \
1752heuristics are switched on."
1753     ); 
1754#endif
1755#ifndef COIN_HAS_CBC
1756  parameters[numberParameters++]=
1757    CbcOrClpParam("log!Level","Level of detail in Solver output",
1758                  -1,63,SOLVERLOGLEVEL);
1759#else
1760  parameters[numberParameters++]=
1761    CbcOrClpParam("log!Level","Level of detail in Coin branch and Cut output",
1762                  -63,63,LOGLEVEL);
1763  parameters[numberParameters-1].setIntValue(1);
1764#endif
1765  parameters[numberParameters-1].setLonghelp
1766    (
1767     "If 0 then there should be no output in normal circumstances.  1 is probably the best\
1768 value for most uses, while 2 and 3 give more information."
1769     ); 
1770  parameters[numberParameters++]=
1771    CbcOrClpParam("max!imize","Set optimization direction to maximize",
1772                  MAXIMIZE,7);
1773  parameters[numberParameters-1].setLonghelp
1774    (
1775     "The default is minimize - use 'maximize' for maximization.\n\
1776You can also use the parameters 'direction maximize'."
1777     ); 
1778#ifdef COIN_HAS_CLP
1779  parameters[numberParameters++]=
1780    CbcOrClpParam("maxF!actor","Maximum number of iterations between \
1781refactorizations",
1782                  1,999999,MAXFACTOR);
1783  parameters[numberParameters-1].setLonghelp
1784    (
1785     "If this is at its initial value of 200 then in this executable clp will guess at a\
1786 value to use.  Otherwise the user can set a value.  The code may decide to re-factorize\
1787 earlier for accuracy."
1788     ); 
1789  parameters[numberParameters++]=
1790    CbcOrClpParam("maxIt!erations","Maximum number of iterations before \
1791stopping",
1792                  0,2147483647,MAXITERATION);
1793  parameters[numberParameters-1].setLonghelp
1794    (
1795     "This can be used for testing purposes.  The corresponding library call\n\
1796      \tsetMaximumIterations(value)\n can be useful.  If the code stops on\
1797 seconds or by an interrupt this will be treated as stopping on maximum iterations"
1798     ); 
1799#endif
1800#ifdef COIN_HAS_CBC
1801  parameters[numberParameters++]=
1802    CbcOrClpParam("maxN!odes","Maximum number of nodes to do",
1803                  0,2147483647,MAXNODES);
1804  parameters[numberParameters-1].setLonghelp
1805    (
1806     "This is a repeatable way to limit search.  Normally using time is easier \
1807but then the results may not be repeatable."
1808     ); 
1809  parameters[numberParameters++]=
1810    CbcOrClpParam("maxS!olutions","Maximum number of solutions to get",
1811                  1,2147483647,MAXSOLS);
1812  parameters[numberParameters-1].setLonghelp
1813    (
1814     "You may want to stop after (say) two solutions or an hour."
1815     ); 
1816#endif
1817  parameters[numberParameters++]=
1818    CbcOrClpParam("min!imize","Set optimization direction to minimize",
1819                  MINIMIZE,7);
1820  parameters[numberParameters-1].setLonghelp
1821    (
1822     "The default is minimize - use 'maximize' for maximization.\n\
1823This should only be necessary if you have previously set maximization \
1824You can also use the parameters 'direction minimize'."
1825     );
1826#ifdef COIN_HAS_CBC
1827  parameters[numberParameters++]=
1828    CbcOrClpParam("mipO!ptions","Dubious options for mip",
1829                  0,COIN_INT_MAX,MIPOPTIONS,false);
1830  parameters[numberParameters++]=
1831    CbcOrClpParam("more!MipOptions","More dubious options for mip",
1832                  -1,COIN_INT_MAX,MOREMIPOPTIONS,false);
1833  parameters[numberParameters++]=
1834    CbcOrClpParam("mixed!IntegerRoundingCuts","Whether to use Mixed Integer Rounding cuts",
1835                  "off",MIXEDCUTS);
1836  parameters[numberParameters-1].append("on");
1837  parameters[numberParameters-1].append("root");
1838  parameters[numberParameters-1].append("ifmove");
1839  parameters[numberParameters-1].append("forceOn");
1840  parameters[numberParameters-1].setLonghelp
1841    (
1842     "This switches on mixed integer rounding cuts (either at root or in entire tree) \
1843See branchAndCut for information on options."
1844     ); 
1845#endif
1846  parameters[numberParameters++]=
1847    CbcOrClpParam("mess!ages","Controls if Clpnnnn is printed",
1848                  "off",MESSAGES);
1849  parameters[numberParameters-1].append("on");
1850  parameters[numberParameters-1].setLonghelp
1851    ("The default behavior is to put out messages such as:\n\
1852   Clp0005 2261  Objective 109.024 Primal infeas 944413 (758)\n\
1853but this program turns this off to make it look more friendly.  It can be useful\
1854 to turn them back on if you want to be able to 'grep' for particular messages or if\
1855 you intend to override the behavior of a particular message."
1856     );
1857#ifdef COIN_HAS_CBC
1858  parameters[numberParameters++]=
1859    CbcOrClpParam("miniT!ree","Size of fast mini tree",
1860                  0,COIN_INT_MAX,NUMBERMINI,false);
1861  parameters[numberParameters-1].setLonghelp
1862    (
1863     "The idea is that I can do a small tree fast. \
1864This is a first try and will hopefully become more sophisticated."
1865     ); 
1866  parameters[numberParameters++]=
1867    CbcOrClpParam("miplib","Do some of miplib test set",
1868                  MIPLIB,3);
1869#endif
1870#ifdef COIN_HAS_CLP
1871  parameters[numberParameters++]=
1872    CbcOrClpParam("netlib","Solve entire netlib test set",
1873                  NETLIB_EITHER,3);
1874  parameters[numberParameters-1].setLonghelp
1875    (
1876     "This exercises the unit test for clp and then solves the netlib test set using dual or primal.\
1877The user can set options before e.g. clp -presolve off -netlib"
1878     ); 
1879#ifdef REAL_BARRIER
1880  parameters[numberParameters++]=
1881    CbcOrClpParam("netlibB!arrier","Solve entire netlib test set with barrier",
1882                  NETLIB_BARRIER,3);
1883  parameters[numberParameters-1].setLonghelp
1884    (
1885     "This exercises the unit test for clp and then solves the netlib test set using barrier.\
1886The user can set options before e.g. clp -kkt on -netlib"
1887     ); 
1888#endif
1889  parameters[numberParameters++]=
1890    CbcOrClpParam("netlibD!ual","Solve entire netlib test set (dual)",
1891                  NETLIB_DUAL,3);
1892  parameters[numberParameters-1].setLonghelp
1893    (
1894     "This exercises the unit test for clp and then solves the netlib test set using dual.\
1895The user can set options before e.g. clp -presolve off -netlib"
1896     ); 
1897  parameters[numberParameters++]=
1898    CbcOrClpParam("netlibP!rimal","Solve entire netlib test set (primal)",
1899                  NETLIB_PRIMAL,3);
1900  parameters[numberParameters-1].setLonghelp
1901    (
1902     "This exercises the unit test for clp and then solves the netlib test set using primal.\
1903The user can set options before e.g. clp -presolve off -netlibp"
1904     ); 
1905  parameters[numberParameters++]=
1906    CbcOrClpParam("netlibT!une","Solve entire netlib test set with 'best' algorithm",
1907                  NETLIB_TUNE,3);
1908  parameters[numberParameters-1].setLonghelp
1909    (
1910     "This exercises the unit test for clp and then solves the netlib test set using whatever \
1911works best.  I know this is cheating but it also stresses the code better by doing a \
1912mixture of stuff.  The best algorithm was chosen on a Linux ThinkPad using native cholesky \
1913with University of Florida ordering."
1914     ); 
1915  parameters[numberParameters++]=
1916    CbcOrClpParam("network","Tries to make network matrix",
1917                  NETWORK,7,false);
1918  parameters[numberParameters-1].setLonghelp
1919    (
1920     "Clp will go faster if the matrix can be converted to a network.  The matrix\
1921 operations may be a bit faster with more efficient storage, but the main advantage\
1922 comes from using a network factorization.  It will probably not be as fast as a \
1923specialized network code."
1924     ); 
1925#ifdef COIN_HAS_CBC
1926  parameters[numberParameters++]=
1927    CbcOrClpParam("node!Strategy","What strategy to use to select nodes",
1928                  "hybrid",NODESTRATEGY);
1929  parameters[numberParameters-1].append("fewest");
1930  parameters[numberParameters-1].append("depth");
1931  parameters[numberParameters-1].append("upfewest");
1932  parameters[numberParameters-1].append("downfewest");
1933  parameters[numberParameters-1].append("updepth");
1934  parameters[numberParameters-1].append("downdepth");
1935  parameters[numberParameters-1].setLonghelp
1936    (
1937     "Normally before a solution the code will choose node with fewest infeasibilities. \
1938You can choose depth as the criterion.  You can also say if up or down branch must \
1939be done first (the up down choice will carry on after solution). \
1940Default has now been changed to hybrid which is breadth first on small depth nodes then fewest."
1941     ); 
1942  parameters[numberParameters++]=
1943    CbcOrClpParam("numberA!nalyze","Number of analysis iterations",
1944                  -COIN_INT_MAX,COIN_INT_MAX,NUMBERANALYZE,false);
1945  parameters[numberParameters-1].setLonghelp
1946    (
1947     "This says how many iterations to spend at root node analyzing problem. \
1948This is a first try and will hopefully become more sophisticated."
1949     ); 
1950#endif
1951  parameters[numberParameters++]=
1952    CbcOrClpParam("objective!Scale","Scale factor to apply to objective",
1953                  -1.0e20,1.0e20,OBJSCALE,false);
1954  parameters[numberParameters-1].setLonghelp
1955    (
1956     "If the objective function has some very large values, you may wish to scale them\
1957 internally by this amount.  It can also be set by autoscale.  It is applied after scaling"
1958     ); 
1959  parameters[numberParameters-1].setDoubleValue(1.0);
1960#endif
1961#ifdef COIN_HAS_CBC
1962  parameters[numberParameters++]=
1963    CbcOrClpParam("outDup!licates","takes duplicate rows etc out of integer model",
1964                  OUTDUPROWS,7,false);
1965#endif
1966  parameters[numberParameters++]=
1967    CbcOrClpParam("output!Format","Which output format to use",
1968                  1,6,OUTPUTFORMAT);
1969  parameters[numberParameters-1].setLonghelp
1970    (
1971     "Normally export will be done using normal representation for numbers and two values\
1972 per line.  You may want to do just one per line (for grep or suchlike) and you may wish\
1973 to save with absolute accuracy using a coded version of the IEEE value. A value of 2 is normal.\
1974 otherwise odd values gives one value per line, even two.  Values 1,2 give normal format, 3,4\
1975 gives greater precision, while 5,6 give IEEE values.  When used for exporting a basis 1 does not save \
1976values, 2 saves values, 3 with greater accuracy and 4 in IEEE."
1977     );
1978#ifdef COIN_HAS_CBC
1979  parameters[numberParameters++]=
1980    CbcOrClpParam("passC!uts","Number of cut passes at root node",
1981                  -999999,999999,CUTPASS);
1982  parameters[numberParameters-1].setLonghelp
1983    (
1984     "The default is 100 passes if less than 500 columns, 100 passes (but \
1985stop if drop small if less than 5000 columns, 20 otherwise"
1986     ); 
1987  parameters[numberParameters++]=
1988    CbcOrClpParam("passF!easibilityPump","How many passes in feasibility pump",
1989                  0,10000,FPUMPITS);
1990  parameters[numberParameters-1].setLonghelp
1991    (
1992     "This fine tunes Feasibility Pump by doing more or fewer passes."
1993     ); 
1994  parameters[numberParameters-1].setIntValue(20);
1995#endif
1996#ifdef COIN_HAS_CLP
1997  parameters[numberParameters++]=
1998    CbcOrClpParam("passP!resolve","How many passes in presolve",
1999                  -200,100,PRESOLVEPASS,false);
2000  parameters[numberParameters-1].setLonghelp
2001    (
2002     "Normally Presolve does 5 passes but you may want to do less to make it\
2003 more lightweight or do more if improvements are still being made.  As Presolve will return\
2004 if nothing is being taken out, you should not normally need to use this fine tuning."
2005     );
2006#endif
2007#ifdef COIN_HAS_CBC
2008  parameters[numberParameters++]=
2009    CbcOrClpParam("passT!reeCuts","Number of cut passes in tree",
2010                  -999999,999999,CUTPASSINTREE);
2011  parameters[numberParameters-1].setLonghelp
2012    (
2013     "The default is one pass"
2014     ); 
2015#endif
2016#ifdef COIN_HAS_CLP
2017  parameters[numberParameters++]=
2018    CbcOrClpParam("pertV!alue","Method of perturbation",
2019                  -5000,102,PERTVALUE,false);
2020  parameters[numberParameters++]=
2021    CbcOrClpParam("perturb!ation","Whether to perturb problem",
2022                  "on",PERTURBATION);
2023  parameters[numberParameters-1].append("off");
2024  parameters[numberParameters-1].setLonghelp
2025    (
2026     "Perturbation helps to stop cycling, but Clp uses other measures for this.\
2027  However large problems and especially ones with unit elements and unit rhs or costs\
2028 benefit from perturbation.  Normally Clp tries to be intelligent, but you can switch this off.\
2029  The Clp library has this off by default.  This program has it on by default."
2030     ); 
2031  parameters[numberParameters++]=
2032    CbcOrClpParam("PFI","Whether to use Product Form of Inverse in simplex",
2033                  "off",PFI,7,false);
2034  parameters[numberParameters-1].append("on");
2035  parameters[numberParameters-1].setLonghelp
2036    (
2037     "By default clp uses Forrest-Tomlin L-U update.  If you are masochistic you can switch it off."
2038     ); 
2039  parameters[numberParameters++]=
2040    CbcOrClpParam("plus!Minus","Tries to make +- 1 matrix",
2041                  PLUSMINUS,7,false);
2042  parameters[numberParameters-1].setLonghelp
2043    (
2044     "Clp will go slightly faster if the matrix can be converted so that the elements are\
2045 not stored and are known to be unit.  The main advantage is memory use.  Clp may automatically\
2046 see if it can convert the problem so you should not need to use this."
2047     ); 
2048  parameters[numberParameters++]=
2049    CbcOrClpParam("pO!ptions","Dubious print options",
2050                  0,COIN_INT_MAX,PRINTOPTIONS,false);
2051  parameters[numberParameters-1].setIntValue(0);
2052  parameters[numberParameters-1].setLonghelp
2053    (
2054     "If this is > 0 then presolve will give more information and branch and cut will give statistics"
2055     ); 
2056  parameters[numberParameters++]=
2057    CbcOrClpParam("preO!pt","Presolve options",
2058                  0,COIN_INT_MAX,PRESOLVEOPTIONS,false);
2059#endif
2060  parameters[numberParameters++]=
2061    CbcOrClpParam("presolve","Whether to presolve problem",
2062                  "on",PRESOLVE);
2063  parameters[numberParameters-1].append("off");
2064  parameters[numberParameters-1].append("more");
2065  parameters[numberParameters-1].append("file");
2066  parameters[numberParameters-1].setLonghelp
2067    (
2068     "Presolve analyzes the model to find such things as redundant equations, equations\
2069 which fix some variables, equations which can be transformed into bounds etc etc.  For the\
2070 initial solve of any problem this is worth doing unless you know that it will have no effect.  \
2071on will normally do 5 passes while using 'more' will do 10.  If the problem is very large you may need \
2072to write the original to file using 'file'."
2073     ); 
2074#ifdef COIN_HAS_CBC
2075  parameters[numberParameters++]=
2076    CbcOrClpParam("preprocess","Whether to use integer preprocessing",
2077                  "off",PREPROCESS);
2078  parameters[numberParameters-1].append("on");
2079  parameters[numberParameters-1].append("save");
2080  parameters[numberParameters-1].append("equal");
2081  parameters[numberParameters-1].append("sos");
2082  parameters[numberParameters-1].append("trysos");
2083  parameters[numberParameters-1].append("equalall");
2084  parameters[numberParameters-1].append("strategy");
2085  parameters[numberParameters-1].setLonghelp
2086    (
2087     "This tries to reduce size of model in a similar way to presolve and \
2088it also tries to strengthen the model - this can be very useful and is worth trying. \
2089 Save option saves on file presolved.mps.  equal will turn <= cliques into \
2090==.  sos will create sos sets if all 0-1 in sets (well one extra is allowed) \
2091and no overlaps.  trysos is same but allows any number extra.  equalall will turn all \
2092valid inequalities into equalities with integer slacks.  strategy is as \
2093on but uses CbcStrategy."
2094     ); 
2095#endif
2096#ifdef COIN_HAS_CLP
2097  parameters[numberParameters++]=
2098    CbcOrClpParam("preT!olerance","Tolerance to use in presolve",
2099                  1.0e-20,1.0e12,PRESOLVETOLERANCE);
2100  parameters[numberParameters-1].setLonghelp
2101    (
2102     "The default is 1.0e-8 - you may wish to try 1.0e-7 if presolve says the problem is \
2103infeasible and you have awkward numbers and you are sure the problem is really feasible."
2104     ); 
2105  parameters[numberParameters++]=
2106    CbcOrClpParam("primalP!ivot","Primal pivot choice algorithm",
2107                  "auto!matic",PRIMALPIVOT);
2108  parameters[numberParameters-1].append("exa!ct");
2109  parameters[numberParameters-1].append("dant!zig");
2110  parameters[numberParameters-1].append("part!ial");
2111  parameters[numberParameters-1].append("steep!est");
2112  parameters[numberParameters-1].append("change");
2113  parameters[numberParameters-1].append("sprint");
2114  parameters[numberParameters-1].setLonghelp
2115    (
2116     "Clp can use any pivot selection algorithm which the user codes as long as it\
2117 implements the features in the abstract pivot base class.  The Dantzig method is implemented\
2118 to show a simple method but its use is deprecated.  Exact devex is the method of choice and there\
2119 are two variants which keep all weights updated but only scan a subset each iteration.\
2120 Partial switches this on while change initially does dantzig until the factorization\
2121 becomes denser.  This is still a work in progress."
2122     ); 
2123  parameters[numberParameters++]=
2124    CbcOrClpParam("primalS!implex","Do primal simplex algorithm",
2125                  PRIMALSIMPLEX);
2126  parameters[numberParameters-1].setLonghelp
2127    (
2128     "This command solves the current model using the primal algorithm.\
2129  The default is to use exact devex.\
2130 The time and iterations may be affected by settings such as presolve, scaling, crash\
2131 and also by column selection  method, infeasibility weight and dual and primal tolerances."
2132     );
2133#endif
2134  parameters[numberParameters++]=
2135    CbcOrClpParam("primalT!olerance","For an optimal solution \
2136no primal infeasibility may exceed this value",
2137                  1.0e-20,1.0e12,PRIMALTOLERANCE);
2138  parameters[numberParameters-1].setLonghelp
2139    (
2140     "Normally the default tolerance is fine, but you may want to increase it a\
2141 bit if a primal run seems to be having a hard time"
2142     ); 
2143#ifdef COIN_HAS_CLP
2144  parameters[numberParameters++]=
2145    CbcOrClpParam("primalW!eight","Initially algorithm acts as if it \
2146costs this much to be infeasible",
2147                  1.0e-20,1.0e20,PRIMALWEIGHT);
2148  parameters[numberParameters-1].setLonghelp
2149    (
2150     "The primal algorithm in Clp is a single phase algorithm as opposed to a two phase\
2151 algorithm where you first get feasible then optimal.  So Clp is minimizing this weight times\
2152 the sum of primal infeasibilities plus the true objective function (in minimization sense).\
2153  Too high a value may mean more iterations, while too low a bound means\
2154 the code may go all the way and then have to increase the weight in order to get feasible.\
2155  OSL had a heuristic to\
2156 adjust bounds, maybe we need that here."
2157     ); 
2158#endif
2159  parameters[numberParameters++]=
2160    CbcOrClpParam("printi!ngOptions","Print options",
2161                  "normal",INTPRINT,3);
2162  parameters[numberParameters-1].append("integer");
2163  parameters[numberParameters-1].append("special");
2164  parameters[numberParameters-1].append("rows");
2165  parameters[numberParameters-1].append("all");
2166  parameters[numberParameters-1].setLonghelp
2167    (
2168     "This changes the amount and format of printing a solution:\nnormal - nonzero column variables \n\
2169integer - nonzero integer column variables\n\
2170special - in format suitable for OsiRowCutDebugger\n\
2171rows - nonzero column variables and row activities\n\
2172all - all column variables and row activities.\n\
2173\nFor non-integer problems 'integer' and 'special' act like 'normal'.  \
2174Also see printMask for controlling output."
2175     ); 
2176  parameters[numberParameters++]=
2177    CbcOrClpParam("printM!ask","Control printing of solution on a  mask",
2178                  PRINTMASK,3);
2179  parameters[numberParameters-1].setLonghelp
2180    (
2181     "If set then only those names which match mask are printed in a solution. \
2182'?' matches any character and '*' matches any set of characters. \
2183 The default is '' i.e. unset so all variables are printed. \
2184This is only active if model has names."
2185     ); 
2186#ifdef COIN_HAS_CBC
2187  parameters[numberParameters++]=
2188    CbcOrClpParam("prio!rityIn","Import priorities etc from file",
2189                  PRIORITYIN,3);
2190  parameters[numberParameters-1].setLonghelp
2191    (
2192     "This will read a file with priorities from the given file name.  It will use the default\
2193 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2194 is initialized to '', i.e. it must be set.  This can not read from compressed files. \
2195File is in csv format with allowed headings - name, number, priority, direction, up, down, solution.  Exactly one of\
2196 name and number must be given."
2197     ); 
2198  parameters[numberParameters++]=
2199    CbcOrClpParam("probing!Cuts","Whether to use Probing cuts",
2200                  "off",PROBINGCUTS);
2201  parameters[numberParameters-1].append("on");
2202  parameters[numberParameters-1].append("root");
2203  parameters[numberParameters-1].append("ifmove");
2204  parameters[numberParameters-1].append("forceOn");
2205  parameters[numberParameters-1].append("forceOnBut");
2206  parameters[numberParameters-1].append("forceOnStrong");
2207  parameters[numberParameters-1].append("forceOnButStrong");
2208  parameters[numberParameters-1].setLonghelp
2209    (
2210     "This switches on probing cuts (either at root or in entire tree) \
2211See branchAndCut for information on options. \
2212but strong options do more probing"
2213     ); 
2214  parameters[numberParameters++]=
2215    CbcOrClpParam("pumpT!une","Dubious ideas for feasibility pump",
2216                  0,100000000,FPUMPTUNE);
2217  parameters[numberParameters-1].setLonghelp
2218    (
2219     "This fine tunes Feasibility Pump \n\
2220\t>=1000000 use as accumulate switch\n\
2221\t>=1000 use index+1 as number of large loops\n\
2222\t>=100 use 0.05 objvalue as increment\n\
2223\t>=10 use +0.1 objvalue for cutoff (add)\n\
2224\t1 == fix ints at bounds, 2 fix all integral ints, 3 and continuous at bounds"
2225     ); 
2226  parameters[numberParameters-1].setIntValue(0);
2227#endif
2228  parameters[numberParameters++]=
2229    CbcOrClpParam("quit","Stops clp execution",
2230                  EXIT);
2231  parameters[numberParameters-1].setLonghelp
2232    (
2233     "This stops the execution of Clp, end, exit, quit and stop are synonyms"
2234     ); 
2235#ifdef COIN_HAS_CBC
2236  parameters[numberParameters++]=
2237    CbcOrClpParam("ratio!Gap","Stop when gap between best possible and \
2238best less than this fraction of larger of two",
2239                  0.0,1.0e20,GAPRATIO);
2240  parameters[numberParameters-1].setDoubleValue(0.0);
2241  parameters[numberParameters-1].setLonghelp
2242    (
2243     "If the gap between best solution and best possible solution is less than this fraction \
2244of the objective value at the root node then the search will terminate.  See 'allowableGap' for a \
2245way of using absolute value rather than fraction."
2246     ); 
2247#endif
2248#ifdef COIN_HAS_CLP
2249  parameters[numberParameters++]=
2250    CbcOrClpParam("reallyO!bjectiveScale","Scale factor to apply to objective in place",
2251                  -1.0e20,1.0e20,OBJSCALE2,false);
2252  parameters[numberParameters-1].setLonghelp
2253    (
2254     "You can set this to -1.0 to test maximization or other to stress code"
2255     ); 
2256  parameters[numberParameters-1].setDoubleValue(1.0);
2257  parameters[numberParameters++]=
2258    CbcOrClpParam("reallyS!cale","Scales model in place",
2259                  REALLY_SCALE,7,false);
2260#endif
2261#ifdef COIN_HAS_CBC
2262    parameters[numberParameters++]=
2263      CbcOrClpParam("reduce!AndSplitCuts","Whether to use Reduce-and-Split cuts",
2264              "off",REDSPLITCUTS);
2265    parameters[numberParameters-1].append("on");
2266    parameters[numberParameters-1].append("root");
2267    parameters[numberParameters-1].append("ifmove");
2268    parameters[numberParameters-1].append("forceOn");
2269    parameters[numberParameters-1].setLonghelp
2270    (
2271     "This switches on reduce and split  cuts (either at root or in entire tree) \
2272See branchAndCut for information on options."
2273     ); 
2274  parameters[numberParameters++]=
2275    CbcOrClpParam("residual!CapacityCuts","Whether to use Residual Capacity cuts",
2276                  "off",RESIDCUTS);
2277  parameters[numberParameters-1].append("on");
2278  parameters[numberParameters-1].append("root");
2279  parameters[numberParameters-1].append("ifmove");
2280  parameters[numberParameters-1].append("forceOn");
2281  parameters[numberParameters-1].setLonghelp
2282    (
2283     "Residual capacity cuts. \
2284See branchAndCut for information on options."
2285     ); 
2286#endif
2287#ifdef COIN_HAS_CLP
2288  parameters[numberParameters++]=
2289    CbcOrClpParam("restore!Model","Restore model from binary file",
2290                  RESTORE);
2291  parameters[numberParameters-1].setLonghelp
2292    (
2293     "This reads data save by saveModel from the given file.  It will use the default\
2294 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2295 is initialized to 'default.prob'."
2296     ); 
2297  parameters[numberParameters++]=
2298    CbcOrClpParam("reverse","Reverses sign of objective",
2299                  REVERSE,7,false);
2300  parameters[numberParameters-1].setLonghelp
2301    (
2302     "Useful for testing if maximization works correctly"
2303     ); 
2304  parameters[numberParameters++]=
2305    CbcOrClpParam("rhs!Scale","Scale factor to apply to rhs and bounds",
2306                  -1.0e20,1.0e20,RHSSCALE,false);
2307  parameters[numberParameters-1].setLonghelp
2308    (
2309     "If the rhs or bounds have some very large meaningful values, you may wish to scale them\
2310 internally by this amount.  It can also be set by autoscale"
2311     ); 
2312  parameters[numberParameters-1].setDoubleValue(1.0);
2313#endif
2314#ifdef COIN_HAS_CBC
2315  parameters[numberParameters++]=
2316      CbcOrClpParam("Rins","Whether to try Relaxed Induced Neighborhood Search",
2317                    "off",RINS);
2318    parameters[numberParameters-1].append("on");
2319  parameters[numberParameters-1].setLonghelp
2320    (
2321     "This switches on Relaxed induced neighborhood Search."
2322     ); 
2323  parameters[numberParameters++]=
2324    CbcOrClpParam("round!ingHeuristic","Whether to use Rounding heuristic",
2325                  "off",ROUNDING);
2326  parameters[numberParameters-1].append("on");
2327  parameters[numberParameters-1].setLonghelp
2328    (
2329     "This switches on a simple (but effective) rounding heuristic at each node of tree."
2330     ); 
2331#endif
2332  parameters[numberParameters++]=
2333    CbcOrClpParam("saveM!odel","Save model to binary file",
2334                  SAVE);
2335  parameters[numberParameters-1].setLonghelp
2336    (
2337     "This will save the problem to the given file name for future use\
2338 by restoreModel.  It will use the default\
2339 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2340 is initialized to 'default.prob'."
2341     ); 
2342  parameters[numberParameters++]=
2343    CbcOrClpParam("saveS!olution","saves solution to file",
2344                  SAVESOL);
2345  parameters[numberParameters-1].setLonghelp
2346    (
2347     "This will write a binary solution file to the given file name.  It will use the default\
2348 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2349 is initialized to 'solution.file'.  To read the file use fread(int) twice to pick up number of rows \
2350and columns, then fread(double) to pick up objective value, then pick up row activities, row duals, column \
2351activities and reduced costs - see bottom of CbcOrClpParam.cpp for code that reads or writes file."
2352     ); 
2353  parameters[numberParameters++]=
2354    CbcOrClpParam("scal!ing","Whether to scale problem",
2355                  "off",SCALING);
2356  parameters[numberParameters-1].append("equi!librium");
2357  parameters[numberParameters-1].append("geo!metric");
2358  parameters[numberParameters-1].append("auto!matic");
2359  parameters[numberParameters-1].setLonghelp
2360    (
2361     "Scaling can help in solving problems which might otherwise fail because of lack of\
2362 accuracy.  It can also reduce the number of iterations.  It is not applied if the range\
2363 of elements is small.  When unscaled it is possible that there may be small primal and/or\
2364 infeasibilities."
2365     ); 
2366  parameters[numberParameters-1].setCurrentOption(3); // say auto
2367#ifndef COIN_HAS_CBC
2368  parameters[numberParameters++]=
2369    CbcOrClpParam("sec!onds","Maximum seconds",
2370                  -1.0,1.0e12,TIMELIMIT);
2371  parameters[numberParameters-1].setLonghelp
2372    (
2373     "After this many seconds clp will act as if maximum iterations had been reached \
2374(if value >=0).  \
2375In this program it is really only useful for testing but the library function\n\
2376      \tsetMaximumSeconds(value)\n can be useful."
2377     );
2378#else
2379  parameters[numberParameters++]=
2380    CbcOrClpParam("sec!onds","maximum seconds",
2381                  -1.0,1.0e12,TIMELIMIT_BAB);
2382  parameters[numberParameters-1].setLonghelp
2383    (
2384     "After this many seconds coin solver will act as if maximum nodes had been reached."
2385     );
2386#endif
2387  parameters[numberParameters++]=
2388    CbcOrClpParam("sleep","for debug",
2389                  DUMMY,7,false);
2390  parameters[numberParameters-1].setLonghelp
2391    (
2392     "If passed to solver fom ampl, then ampl will wait so that you can copy .nl file for debug."
2393     ); 
2394#ifdef COIN_HAS_CLP
2395  parameters[numberParameters++]=
2396    CbcOrClpParam("slp!Value","Number of slp passes before primal",
2397                  -1,50000,SLPVALUE,false);
2398  parameters[numberParameters-1].setLonghelp
2399    (
2400     "If you are solving a quadratic problem using primal then it may be helpful to do some \
2401sequential Lps to get a good approximate solution."
2402     ); 
2403#endif
2404  parameters[numberParameters++]=
2405    CbcOrClpParam("solu!tion","Prints solution to file",
2406                  SOLUTION);
2407  parameters[numberParameters-1].setLonghelp
2408    (
2409     "This will write a primitive solution file to the given file name.  It will use the default\
2410 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2411 is initialized to 'stdout'.  The amount of output can be varied using printi!ngOptions or printMask."
2412     ); 
2413#ifdef COIN_HAS_CLP
2414#ifdef COIN_HAS_CBC
2415  parameters[numberParameters++]=
2416    CbcOrClpParam("solv!e","Solve problem",
2417                  BAB);
2418  parameters[numberParameters-1].setLonghelp
2419    (
2420     "If there are no integer variables then this just solves LP.  If there are integer variables \
2421this does branch and cut."
2422     ); 
2423  parameters[numberParameters++]=
2424    CbcOrClpParam("sos!Options","Whether to use SOS from AMPL",
2425                  "off",SOS);
2426  parameters[numberParameters-1].append("on");
2427  parameters[numberParameters-1].setCurrentOption("on");
2428  parameters[numberParameters-1].setLonghelp
2429    (
2430     "Normally if AMPL says there are SOS variables they should be used, but sometime sthey should\
2431 be turned off - this does so."
2432     ); 
2433  parameters[numberParameters++]=
2434    CbcOrClpParam("slog!Level","Level of detail in Solver output",
2435                  -1,63,SOLVERLOGLEVEL);
2436  parameters[numberParameters-1].setLonghelp
2437    (
2438     "If 0 then there should be no output in normal circumstances.  1 is probably the best\
2439 value for most uses, while 2 and 3 give more information."
2440     );
2441#else
2442  // allow solve as synonym for dual
2443  parameters[numberParameters++]=
2444    CbcOrClpParam("solv!e","Solve problem using dual simplex",
2445                  BAB);
2446  parameters[numberParameters-1].setLonghelp
2447    (
2448     "Just so can use solve for clp as well as in cbc"
2449     ); 
2450#endif
2451#endif
2452#ifdef COIN_HAS_CLP
2453  parameters[numberParameters++]=
2454    CbcOrClpParam("spars!eFactor","Whether factorization treated as sparse",
2455                  "on",SPARSEFACTOR,7,false);
2456  parameters[numberParameters-1].append("off");
2457  parameters[numberParameters++]=
2458    CbcOrClpParam("special!Options","Dubious options for Simplex - see ClpSimplex.hpp",
2459                  0,COIN_INT_MAX,SPECIALOPTIONS,false);
2460  parameters[numberParameters++]=
2461    CbcOrClpParam("sprint!Crash","Whether to try sprint crash",
2462                  -1,5000000,SPRINT);
2463  parameters[numberParameters-1].setLonghelp
2464    (
2465     "For long and thin problems this program may solve a series of small problems\
2466 created by taking a subset of the columns.  I introduced the idea as 'Sprint' after\
2467 an LP code of that name of the 60's which tried the same tactic (not totally successfully).\
2468  Cplex calls it 'sifting'.  -1 is automatic choice, 0 is off, n is number of passes"
2469     ); 
2470  parameters[numberParameters++]=
2471    CbcOrClpParam("stat!istics","Print some statistics",
2472                  STATISTICS);
2473  parameters[numberParameters-1].setLonghelp
2474    (
2475     "This command prints some statistics for the current model.\
2476 If log level >1 then more is printed.\
2477 These are for presolved model if presolve on (and unscaled)."
2478     );
2479#endif
2480  parameters[numberParameters++]=
2481    CbcOrClpParam("stop","Stops clp execution",
2482                  EXIT);
2483  parameters[numberParameters-1].setLonghelp
2484    (
2485     "This stops the execution of Clp, end, exit, quit and stop are synonyms"
2486     ); 
2487#ifdef COIN_HAS_CBC
2488  parameters[numberParameters++]=
2489    CbcOrClpParam("strengthen","Create strengthened problem",
2490                  STRENGTHEN,3);
2491  parameters[numberParameters-1].setLonghelp
2492    (
2493     "This creates a new problem by applying the root node cuts.  All tight constraints \
2494will be in resulting problem"
2495     ); 
2496  parameters[numberParameters++]=
2497    CbcOrClpParam("strong!Branching","Number of variables to look at in strong branching",
2498                  0,999999,STRONGBRANCHING);
2499  parameters[numberParameters-1].setLonghelp
2500    (
2501     "In order to decide which variable to branch on, the code will choose up to this number \
2502of unsatisfied variables to do mini up and down branches on.  Then the most effective one is chosen. \
2503If a variable is branched on many times then the previous average up and down costs may be used - \
2504see number before trust."
2505     ); 
2506#endif
2507#ifdef COIN_HAS_CLP
2508  parameters[numberParameters++]=
2509    CbcOrClpParam("subs!titution","How long a column to substitute for in presolve",
2510                  0,10000,SUBSTITUTION,false);
2511  parameters[numberParameters-1].setLonghelp
2512    (
2513     "Normally Presolve gets rid of 'free' variables when there are no more than 3 \
2514 variables in column.  If you increase this the number of rows may decrease but number of \
2515 elements may increase."
2516     ); 
2517#endif
2518#ifdef COIN_HAS_CBC
2519  parameters[numberParameters++]=
2520    CbcOrClpParam("testO!si","Test OsiObject stuff",
2521                  -1,COIN_INT_MAX,TESTOSI,false);
2522#endif
2523#ifdef CBC_THREAD
2524  parameters[numberParameters++]=
2525    CbcOrClpParam("thread!s","Number of threads to try and use",
2526                  -100,10000,THREADS,false);
2527  parameters[numberParameters-1].setLonghelp
2528    (
2529     "To use multiple threads, set threads to number wanted.  It may be better \
2530to use one or two more than number of cpus available.  If 100+n then n threads and \
2531threads used in sub-trees, if 200+n use threads for root cuts, 300+n - both."
2532     ); 
2533#endif
2534#ifdef COIN_HAS_CBC
2535  parameters[numberParameters++]=
2536    CbcOrClpParam("tighten!Factor","Tighten bounds using this times largest \
2537activity at continuous solution",
2538                  1.0e-3,1.0e20,TIGHTENFACTOR,false);
2539  parameters[numberParameters-1].setLonghelp
2540    (
2541     "This sleazy trick can help on some problems."
2542     ); 
2543#endif
2544#ifdef COIN_HAS_CLP
2545  parameters[numberParameters++]=
2546    CbcOrClpParam("tightLP","Poor person's preSolve for now",
2547                  TIGHTEN,7,false);
2548#endif
2549#ifdef COIN_HAS_CBC
2550  parameters[numberParameters++]=
2551    CbcOrClpParam("trust!PseudoCosts","Number of branches before we trust pseudocosts",
2552                  -1,2000000,NUMBERBEFORE);
2553  parameters[numberParameters-1].setLonghelp
2554    (
2555     "Using strong branching computes pseudo-costs.  After this many times for a variable we just \
2556trust the pseudo costs and do not do any more strong branching."
2557     ); 
2558#endif
2559#ifdef COIN_HAS_CBC
2560  parameters[numberParameters++]=
2561    CbcOrClpParam("tune!PreProcess","Dubious tuning parameters",
2562                  0,20000000,PROCESSTUNE,false);
2563  parameters[numberParameters-1].setLonghelp
2564    (
2565     "For making equality cliques this is minimumsize.  Also for adding \
2566integer slacks.  May be used for more later \
2567If <1000 that is what it does.  If <1000000 - numberPasses is (value/1000)-1 and tune is tune %1000. \
2568If >= 1000000! - numberPasses is (value/1000000)-1 and tune is tune %1000000.  In this case if tune is now still >=10000 \
2569numberPassesPerInnerLoop is changed from 10 to (tune-10000)-1 and tune becomes tune % 10000!!!!! - happy? - \
2570so to keep normal limit on cliques of 5, do 3 major passes (include presolves) but only doing one tightening pass per major pass - \
2571you would use 3010005 (I think)"
2572     ); 
2573  parameters[numberParameters++]=
2574    CbcOrClpParam("two!MirCuts","Whether to use Two phase Mixed Integer Rounding cuts",
2575                  "off",TWOMIRCUTS);
2576  parameters[numberParameters-1].append("on");
2577  parameters[numberParameters-1].append("root");
2578  parameters[numberParameters-1].append("ifmove");
2579  parameters[numberParameters-1].append("forceOn");
2580  parameters[numberParameters-1].setLonghelp
2581    (
2582     "This switches on two phase mixed integer rounding  cuts (either at root or in entire tree) \
2583See branchAndCut for information on options."
2584     ); 
2585#endif
2586  parameters[numberParameters++]=
2587    CbcOrClpParam("unitTest","Do unit test",
2588                  UNITTEST,3);
2589  parameters[numberParameters-1].setLonghelp
2590    (
2591     "This exercises the unit test for clp"
2592     ); 
2593  parameters[numberParameters++]=
2594    CbcOrClpParam("userClp","Hand coded Clp stuff",
2595                  USERCLP);
2596  parameters[numberParameters-1].setLonghelp
2597    (
2598     "There are times e.g. when using AMPL interface when you may wish to do something unusual.  \
2599Look for USERCLP in main driver and modify sample code."
2600     ); 
2601#ifdef COIN_HAS_CBC
2602  parameters[numberParameters++]=
2603    CbcOrClpParam("userCbc","Hand coded Cbc stuff",
2604                  USERCBC);
2605  parameters[numberParameters-1].setLonghelp
2606    (
2607     "There are times e.g. when using AMPL interface when you may wish to do something unusual.  \
2608Look for USERCBC in main driver and modify sample code."
2609     ); 
2610#endif
2611  parameters[numberParameters++]=
2612    CbcOrClpParam("vector","Whether to use vector? Form of matrix in simplex",
2613                  "off",VECTOR,7,false);
2614  parameters[numberParameters-1].append("on");
2615  parameters[numberParameters-1].setLonghelp
2616    (
2617     "If this is on and ClpPackedMatrix uses extra column copy in odd format."
2618     ); 
2619  parameters[numberParameters++]=
2620    CbcOrClpParam("verbose","Switches on longer help on single ?",
2621                  0,15,VERBOSE,false);
2622  parameters[numberParameters-1].setLonghelp
2623    (
2624     "Set to 1 to get short help with ? list, 2 to get long help, 3 for both.  (add 4 to just get ampl ones)."
2625     ); 
2626  parameters[numberParameters-1].setIntValue(0);
2627  assert(numberParameters<CBCMAXPARAMETERS);
2628}
2629// Given a parameter type - returns its number in list
2630int whichParam (CbcOrClpParameterType name, 
2631                int numberParameters, CbcOrClpParam *const parameters)
2632{
2633  int i;
2634  for (i=0;i<numberParameters;i++) {
2635    if (parameters[i].type()==name)
2636      break;
2637  }
2638  assert (i<numberParameters);
2639  return i;
2640}
2641#ifdef COIN_HAS_CLP
2642// Dump a solution to file
2643void saveSolution(const ClpSimplex * lpSolver,std::string fileName)
2644{
2645  FILE * fp=fopen(fileName.c_str(),"wb");
2646  if (fp) {
2647    int numberRows=lpSolver->numberRows();
2648    int numberColumns=lpSolver->numberColumns();
2649    double objectiveValue = lpSolver->objectiveValue();
2650    fwrite(&numberRows,sizeof(int),1,fp);
2651    fwrite(&numberColumns,sizeof(int),1,fp);
2652    fwrite(&objectiveValue,sizeof(double),1,fp);
2653    double * dualRowSolution = lpSolver->dualRowSolution();
2654    double * primalRowSolution = lpSolver->primalRowSolution();
2655    fwrite(primalRowSolution,sizeof(double),numberRows,fp);
2656    fwrite(dualRowSolution,sizeof(double),numberRows,fp);
2657    double * dualColumnSolution = lpSolver->dualColumnSolution();
2658    double * primalColumnSolution = lpSolver->primalColumnSolution();
2659    fwrite(primalColumnSolution,sizeof(double),numberColumns,fp);
2660    fwrite(dualColumnSolution,sizeof(double),numberColumns,fp);
2661    fclose(fp);
2662  } else {
2663    std::cout<<"Unable to open file "<<fileName<<std::endl;
2664  }
2665}
2666/* Restore a solution from file.
2667   mode 0 normal, 1 swap rows and columns and primal and dual
2668   if 2 set then also change signs
2669*/
2670void restoreSolution(ClpSimplex * lpSolver,std::string fileName,int mode)
2671{
2672  FILE * fp=fopen(fileName.c_str(),"rb");
2673  if (fp) {
2674    int numberRows=lpSolver->numberRows();
2675    int numberColumns=lpSolver->numberColumns();
2676    int numberRowsFile;
2677    int numberColumnsFile;
2678    double objectiveValue;
2679    fread(&numberRowsFile,sizeof(int),1,fp);
2680    fread(&numberColumnsFile,sizeof(int),1,fp);
2681    fread(&objectiveValue,sizeof(double),1,fp);
2682    double * dualRowSolution = lpSolver->dualRowSolution();
2683    double * primalRowSolution = lpSolver->primalRowSolution();
2684    double * dualColumnSolution = lpSolver->dualColumnSolution();
2685    double * primalColumnSolution = lpSolver->primalColumnSolution();
2686    if (mode) {
2687      // swap
2688      int k=numberRows;
2689      numberRows=numberColumns;
2690      numberColumns=k;
2691      double * temp;
2692      temp = dualRowSolution;
2693      dualRowSolution = primalColumnSolution;
2694      primalColumnSolution=temp;
2695      temp = dualColumnSolution;
2696      dualColumnSolution = primalRowSolution;
2697      primalRowSolution=temp;
2698    }
2699    if (numberRows!=numberRowsFile||numberColumns!=numberColumnsFile) {
2700      std::cout<<"Mismatch on rows and/or columns"<<std::endl;
2701    } else {
2702      lpSolver->setObjectiveValue(objectiveValue);
2703      fread(primalRowSolution,sizeof(double),numberRows,fp);
2704      fread(dualRowSolution,sizeof(double),numberRows,fp);
2705      fread(primalColumnSolution,sizeof(double),numberColumns,fp);
2706      fread(dualColumnSolution,sizeof(double),numberColumns,fp);
2707      if (mode==3) {
2708        int i;
2709        for (i=0;i<numberRows;i++) {
2710          primalRowSolution[i] = -primalRowSolution[i];
2711          dualRowSolution[i] = -dualRowSolution[i];
2712        }
2713        for (i=0;i<numberColumns;i++) {
2714          primalColumnSolution[i] = -primalColumnSolution[i];
2715          dualColumnSolution[i] = -dualColumnSolution[i];
2716        }
2717      }
2718    }
2719    fclose(fp);
2720  } else {
2721    std::cout<<"Unable to open file "<<fileName<<std::endl;
2722  }
2723}
2724#endif
Note: See TracBrowser for help on using the repository browser.