source: trunk/Clp/src/CbcOrClpParam.cpp @ 1054

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

changes to compile under gcc 4.3

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 94.0 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  parameters[numberParameters++]=
1382    CbcOrClpParam("direction","Minimize or Maximize",
1383                  "min!imize",DIRECTION);
1384  parameters[numberParameters-1].append("max!imize");
1385  parameters[numberParameters-1].append("zero");
1386  parameters[numberParameters-1].setLonghelp
1387    (
1388     "The default is minimize - use 'direction maximize' for maximization.\n\
1389You can also use the parameters 'maximize' or 'minimize'."
1390     ); 
1391  parameters[numberParameters++]=
1392    CbcOrClpParam("directory","Set Default directory for import etc.",
1393                  DIRECTORY);
1394  parameters[numberParameters-1].setLonghelp
1395    (
1396     "This sets the directory which import, export, saveModel, restoreModel etc will use.\
1397  It is initialized to './'"
1398     ); 
1399#ifdef COIN_HAS_CLP
1400  parameters[numberParameters++]=
1401    CbcOrClpParam("dualB!ound","Initially algorithm acts as if no \
1402gap between bounds exceeds this value",
1403                  1.0e-20,1.0e12,DUALBOUND);
1404  parameters[numberParameters-1].setLonghelp
1405    (
1406     "The dual algorithm in Clp is a single phase algorithm as opposed to a two phase\
1407 algorithm where you first get feasible then optimal.  If a problem has both upper and\
1408 lower bounds then it is trivial to get dual feasible by setting non basic variables\
1409 to correct bound.  If the gap between the upper and lower bounds of a variable is more\
1410 than the value of dualBound Clp introduces fake bounds so that it can make the problem\
1411 dual feasible.  This has the same effect as a composite objective function in the\
1412 primal algorithm.  Too high a value may mean more iterations, while too low a bound means\
1413 the code may go all the way and then have to increase the bounds.  OSL had a heuristic to\
1414 adjust bounds, maybe we need that here."
1415     );
1416  parameters[numberParameters++]=
1417    CbcOrClpParam("dualize","Solves dual reformulation",
1418                  0,2,DUALIZE,false);
1419  parameters[numberParameters-1].setLonghelp
1420    (
1421     "Don't even think about it."
1422     ); 
1423  parameters[numberParameters++]=
1424    CbcOrClpParam("dualP!ivot","Dual pivot choice algorithm",
1425                  "auto!matic",DUALPIVOT);
1426  parameters[numberParameters-1].append("dant!zig");
1427  parameters[numberParameters-1].append("partial");
1428  parameters[numberParameters-1].append("steep!est");
1429  parameters[numberParameters-1].setLonghelp
1430    (
1431     "Clp can use any pivot selection algorithm which the user codes as long as it\
1432 implements the features in the abstract pivot base class.  The Dantzig method is implemented\
1433 to show a simple method but its use is deprecated.  Steepest is the method of choice and there\
1434 are two variants which keep all weights updated but only scan a subset each iteration.\
1435 Partial switches this on while automatic decides at each iteration based on information\
1436 about the factorization."
1437     ); 
1438  parameters[numberParameters++]=
1439    CbcOrClpParam("dualS!implex","Do dual simplex algorithm",
1440                  DUALSIMPLEX);
1441  parameters[numberParameters-1].setLonghelp
1442    (
1443     "This command solves the current model using the dual steepest edge algorithm.\
1444The time and iterations may be affected by settings such as presolve, scaling, crash\
1445 and also by dual pivot method, fake bound on variables and dual and primal tolerances."
1446     );
1447#endif
1448  parameters[numberParameters++]=
1449    CbcOrClpParam("dualT!olerance","For an optimal solution \
1450no dual infeasibility may exceed this value",
1451                  1.0e-20,1.0e12,DUALTOLERANCE);
1452  parameters[numberParameters-1].setLonghelp
1453    (
1454     "Normally the default tolerance is fine, but you may want to increase it a\
1455 bit if a dual run seems to be having a hard time.  One method which can be faster is \
1456to use a large tolerance e.g. 1.0e-4 and dual and then clean up problem using primal and the \
1457correct tolerance (remembering to switch off presolve for this final short clean up phase)."
1458     ); 
1459#ifdef COIN_HAS_CLP
1460  parameters[numberParameters++]=
1461    CbcOrClpParam("either!Simplex","Do dual or primal simplex algorithm",
1462                  EITHERSIMPLEX);
1463  parameters[numberParameters-1].setLonghelp
1464    (
1465     "This command solves the current model using the dual or primal algorithm,\
1466 based on a dubious analysis of model."
1467     );
1468#endif
1469  parameters[numberParameters++]=
1470    CbcOrClpParam("end","Stops clp execution",
1471                  EXIT);
1472  parameters[numberParameters-1].setLonghelp
1473    (
1474     "This stops execution ; end, exit, quit and stop are synonyms"
1475     ); 
1476  parameters[numberParameters++]=
1477    CbcOrClpParam("error!sAllowed","Whether to allow import errors",
1478                  "off",ERRORSALLOWED,3);
1479  parameters[numberParameters-1].append("on");
1480  parameters[numberParameters-1].setLonghelp
1481    (
1482     "The default is not to use any model which had errors when reading the mps file.\
1483  Setting this to 'on' will allow all errors from which the code can recover\
1484 simply by ignoring the error.  There are some errors from which the code can not recover \
1485e.g. no ENDATA.  This has to be set before import i.e. -errorsAllowed on -import xxxxxx.mps."
1486     );
1487  parameters[numberParameters++]=
1488    CbcOrClpParam("exit","Stops clp execution",
1489                  EXIT);
1490  parameters[numberParameters-1].setLonghelp
1491    (
1492     "This stops the execution of Clp, end, exit, quit and stop are synonyms"
1493     ); 
1494  parameters[numberParameters++]=
1495    CbcOrClpParam("export","Export model as mps file",
1496                  EXPORT);
1497  parameters[numberParameters-1].setLonghelp
1498    (
1499     "This will write an MPS format file to the given file name.  It will use the default\
1500 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
1501 is initialized to 'default.mps'."
1502     ); 
1503#ifdef COIN_HAS_CBC
1504  parameters[numberParameters++]=
1505    CbcOrClpParam("extra1","Extra integer parameter 1",
1506                  -1,COIN_INT_MAX,EXTRA1,false);
1507  parameters[numberParameters-1].setIntValue(-1);
1508  parameters[numberParameters++]=
1509    CbcOrClpParam("extra2","Extra integer parameter 2",
1510                  -1,COIN_INT_MAX,EXTRA2,false);
1511  parameters[numberParameters-1].setIntValue(-1);
1512  parameters[numberParameters++]=
1513    CbcOrClpParam("extra3","Extra integer parameter 3",
1514                  -1,COIN_INT_MAX,EXTRA3,false);
1515  parameters[numberParameters-1].setIntValue(-1);
1516  parameters[numberParameters++]=
1517    CbcOrClpParam("extra4","Extra integer parameter 4",
1518                  -1,COIN_INT_MAX,EXTRA4,false);
1519  parameters[numberParameters-1].setIntValue(-1);
1520#endif
1521#ifdef COIN_HAS_CLP
1522  parameters[numberParameters++]=
1523    CbcOrClpParam("fakeB!ound","All bounds <= this value - DEBUG",
1524                  1.0,1.0e15,FAKEBOUND,false);
1525#ifdef COIN_HAS_CBC
1526    parameters[numberParameters++]=
1527      CbcOrClpParam("feas!ibilityPump","Whether to try Feasibility Pump",
1528                    "off",FPUMP);
1529    parameters[numberParameters-1].append("on");
1530  parameters[numberParameters-1].setLonghelp
1531    (
1532     "This switches on feasibility pump heuristic at root. This is due to Fischetti and Lodi \
1533and uses a sequence of Lps to try and get an integer feasible solution. \
1534Some fine tuning is available by passFeasibilityPump."
1535     ); 
1536  parameters[numberParameters++]=
1537    CbcOrClpParam("fix!OnDj","Try heuristic based on fixing variables with \
1538reduced costs greater than this",
1539                  -1.0e20,1.0e20,DJFIX,false);
1540  parameters[numberParameters-1].setLonghelp
1541    (
1542     "If this is set integer variables with reduced costs greater than this will be fixed \
1543before branch and bound - use with extreme caution!" 
1544     ); 
1545    parameters[numberParameters++]=
1546      CbcOrClpParam("flow!CoverCuts","Whether to use Flow Cover cuts",
1547                    "off",FLOWCUTS);
1548    parameters[numberParameters-1].append("on");
1549    parameters[numberParameters-1].append("root");
1550    parameters[numberParameters-1].append("ifmove");
1551    parameters[numberParameters-1].append("forceOn");
1552    parameters[numberParameters-1].setLonghelp
1553    (
1554     "This switches on flow cover cuts (either at root or in entire tree) \
1555See branchAndCut for information on options."
1556     ); 
1557    parameters[numberParameters++]=
1558      CbcOrClpParam("force!Solution","Whether to use given solution as crash for BAB",
1559                    "off",USESOLUTION);
1560    parameters[numberParameters-1].append("on");
1561  parameters[numberParameters-1].setLonghelp
1562    (
1563     "If on then tries to branch to solution given by AMPL or priorities file."
1564     ); 
1565#endif
1566  parameters[numberParameters++]=
1567    CbcOrClpParam("gamma!(Delta)","Whether to regularize barrier",
1568                  "off",GAMMA,7,false);
1569  parameters[numberParameters-1].append("on");
1570  parameters[numberParameters-1].append("gamma");
1571  parameters[numberParameters-1].append("delta");
1572  parameters[numberParameters-1].append("onstrong");
1573  parameters[numberParameters-1].append("gammastrong");
1574  parameters[numberParameters-1].append("deltastrong");
1575#endif
1576#ifdef COIN_HAS_CBC
1577  parameters[numberParameters++]=
1578    CbcOrClpParam("gomory!Cuts","Whether to use Gomory cuts",
1579                  "off",GOMORYCUTS);
1580  parameters[numberParameters-1].append("on");
1581  parameters[numberParameters-1].append("root");
1582  parameters[numberParameters-1].append("ifmove");
1583  parameters[numberParameters-1].append("forceOn");
1584  parameters[numberParameters-1].setLonghelp
1585    (
1586     "The original cuts - beware of imitations!  Having gone out of favor, they are now more \
1587fashionable as LP solvers are more robust and they interact well with other cuts.  They will almost always \
1588give cuts (although in this executable they are limited as to number of variables in cut).  \
1589However the cuts may be dense so it is worth experimenting. \
1590See branchAndCut for information on options."
1591     ); 
1592  parameters[numberParameters++]=
1593    CbcOrClpParam("greedy!Heuristic","Whether to use a greedy heuristic",
1594                  "off",GREEDY);
1595  parameters[numberParameters-1].append("on");
1596  parameters[numberParameters-1].append("root");
1597  parameters[numberParameters-1].setLonghelp
1598    (
1599     "Switches on a greedy heuristic which will try and obtain a solution.  It may just fix a \
1600percentage of variables and then try a small branch and cut run."
1601     ); 
1602  parameters[numberParameters++]=
1603    CbcOrClpParam("heur!isticsOnOff","Switches most heuristics on or off",
1604                  "off",HEURISTICSTRATEGY);
1605  parameters[numberParameters-1].append("on");
1606  parameters[numberParameters-1].setLonghelp
1607    (
1608     "This can be used to switch on or off all heuristics.  Then you can do \
1609individual ones off or on.  CbcTreeLocal is not included as it dramatically \
1610alters search."
1611     ); 
1612#endif
1613  parameters[numberParameters++]=
1614    CbcOrClpParam("help","Print out version, non-standard options and some help",
1615                  HELP,3);
1616  parameters[numberParameters-1].setLonghelp
1617    (
1618     "This prints out some help to get user started.  If you have printed this then \
1619you should be past that stage:-)"
1620     ); 
1621#ifdef COIN_HAS_CBC
1622  parameters[numberParameters++]=
1623    CbcOrClpParam("hot!StartMaxIts","Maximum iterations on hot start",
1624                  0,COIN_INT_MAX,MAXHOTITS,false);
1625#endif
1626#ifdef COIN_HAS_CLP
1627  parameters[numberParameters++]=
1628    CbcOrClpParam("idiot!Crash","Whether to try idiot crash",
1629                  -1,999999,IDIOT);
1630  parameters[numberParameters-1].setLonghelp
1631    (
1632     "This is a type of 'crash' which works well on some homogeneous problems.\
1633 It works best on problems with unit elements and rhs but will do something to any model.  It should only be\
1634 used before primal.  It can be set to -1 when the code decides for itself whether to use it,\
1635 0 to switch off or n > 0 to do n passes."
1636     ); 
1637#endif
1638  parameters[numberParameters++]=
1639    CbcOrClpParam("import","Import model from mps file",
1640                  IMPORT,3);
1641  parameters[numberParameters-1].setLonghelp
1642    (
1643     "This will read an MPS format file from the given file name.  It will use the default\
1644 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
1645 is initialized to '', i.e. it must be set.  If you have libgz then it can read compressed\
1646 files 'xxxxxxxx.gz'.."
1647     );
1648#ifdef COIN_HAS_CBC
1649  parameters[numberParameters++]=
1650    CbcOrClpParam("inc!rement","A valid solution must be at least this \
1651much better than last integer solution",
1652                  -1.0e20,1.0e20,INCREMENT);
1653  parameters[numberParameters-1].setLonghelp
1654    (
1655     "Whenever a solution is found the bound on solutions is set to solution (in a minimization\
1656sense) plus this.  If it is not set then the code will try and work one out e.g. if \
1657all objective coefficients are multiples of 0.01 and only integer variables have entries in \
1658objective then this can be set to 0.01.  Be careful if you set this negative!"
1659     ); 
1660  parameters[numberParameters++]=
1661    CbcOrClpParam("inf!easibilityWeight","Each integer infeasibility is expected \
1662to cost this much",
1663                  0.0,1.0e20,INFEASIBILITYWEIGHT);
1664  parameters[numberParameters-1].setLonghelp
1665    (
1666     "A primitive way of deciding which node to explore next.  Satisfying each integer infeasibility is \
1667expected to cost this much."
1668     ); 
1669  parameters[numberParameters++]=
1670    CbcOrClpParam("initialS!olve","Solve to continuous",
1671                  SOLVECONTINUOUS);
1672  parameters[numberParameters-1].setLonghelp
1673    (
1674     "This just solves the problem to continuous - without adding any cuts"
1675     ); 
1676  parameters[numberParameters++]=
1677    CbcOrClpParam("integerT!olerance","For an optimal solution \
1678no integer variable may be this away from an integer value",
1679              1.0e-20,0.5,INTEGERTOLERANCE);
1680  parameters[numberParameters-1].setLonghelp
1681    (
1682     "Beware of setting this smaller than the primal tolerance."
1683     ); 
1684#endif
1685#ifdef COIN_HAS_CLP
1686  parameters[numberParameters++]=
1687    CbcOrClpParam("keepN!ames","Whether to keep names from import",
1688                  "on",KEEPNAMES);
1689  parameters[numberParameters-1].append("off");
1690  parameters[numberParameters-1].setLonghelp
1691    (
1692     "It saves space to get rid of names so if you need to you can set this to off.  \
1693This needs to be set before the import of model - so -keepnames off -import xxxxx.mps."
1694     ); 
1695  parameters[numberParameters++]=
1696    CbcOrClpParam("KKT","Whether to use KKT factorization",
1697                  "off",KKT,7,false);
1698  parameters[numberParameters-1].append("on");
1699#endif
1700#ifdef COIN_HAS_CBC
1701  parameters[numberParameters++]=
1702    CbcOrClpParam("knapsack!Cuts","Whether to use Knapsack cuts",
1703                  "off",KNAPSACKCUTS);
1704  parameters[numberParameters-1].append("on");
1705  parameters[numberParameters-1].append("root");
1706  parameters[numberParameters-1].append("ifmove");
1707  parameters[numberParameters-1].append("forceOn");
1708  parameters[numberParameters-1].setLonghelp
1709    (
1710     "This switches on knapsack cuts (either at root or in entire tree) \
1711See branchAndCut for information on options."
1712     ); 
1713  parameters[numberParameters++]=
1714    CbcOrClpParam("lift!AndProjectCuts","Whether to use Lift and Project cuts",
1715                  "off",LANDPCUTS);
1716  parameters[numberParameters-1].append("on");
1717  parameters[numberParameters-1].append("root");
1718  parameters[numberParameters-1].append("ifmove");
1719  parameters[numberParameters-1].append("forceOn");
1720  parameters[numberParameters-1].setLonghelp
1721    (
1722     "Lift and project cuts - may be expensive to compute. \
1723See branchAndCut for information on options."
1724     ); 
1725  parameters[numberParameters++]=
1726    CbcOrClpParam("local!TreeSearch","Whether to use local treesearch",
1727                  "off",LOCALTREE);
1728  parameters[numberParameters-1].append("on");
1729  parameters[numberParameters-1].setLonghelp
1730    (
1731     "This switches on a local search algorithm when a solution is found.  This is from \
1732Fischetti and Lodi and is not really a heuristic although it can be used as one. \
1733When used from Coin solve it has limited functionality.  It is not switched on when \
1734heuristics are switched on."
1735     ); 
1736#endif
1737#ifndef COIN_HAS_CBC
1738  parameters[numberParameters++]=
1739    CbcOrClpParam("log!Level","Level of detail in Solver output",
1740                  -1,63,SOLVERLOGLEVEL);
1741#else
1742  parameters[numberParameters++]=
1743    CbcOrClpParam("log!Level","Level of detail in Coin branch and Cut output",
1744                  -63,63,LOGLEVEL);
1745  parameters[numberParameters-1].setIntValue(1);
1746#endif
1747  parameters[numberParameters-1].setLonghelp
1748    (
1749     "If 0 then there should be no output in normal circumstances.  1 is probably the best\
1750 value for most uses, while 2 and 3 give more information."
1751     ); 
1752  parameters[numberParameters++]=
1753    CbcOrClpParam("max!imize","Set optimization direction to maximize",
1754                  MAXIMIZE,7);
1755  parameters[numberParameters-1].setLonghelp
1756    (
1757     "The default is minimize - use 'maximize' for maximization.\n\
1758You can also use the parameters 'direction maximize'."
1759     ); 
1760#ifdef COIN_HAS_CLP
1761  parameters[numberParameters++]=
1762    CbcOrClpParam("maxF!actor","Maximum number of iterations between \
1763refactorizations",
1764                  1,999999,MAXFACTOR);
1765  parameters[numberParameters-1].setLonghelp
1766    (
1767     "If this is at its initial value of 200 then in this executable clp will guess at a\
1768 value to use.  Otherwise the user can set a value.  The code may decide to re-factorize\
1769 earlier for accuracy."
1770     ); 
1771  parameters[numberParameters++]=
1772    CbcOrClpParam("maxIt!erations","Maximum number of iterations before \
1773stopping",
1774                  0,2147483647,MAXITERATION);
1775  parameters[numberParameters-1].setLonghelp
1776    (
1777     "This can be used for testing purposes.  The corresponding library call\n\
1778      \tsetMaximumIterations(value)\n can be useful.  If the code stops on\
1779 seconds or by an interrupt this will be treated as stopping on maximum iterations"
1780     ); 
1781#endif
1782#ifdef COIN_HAS_CBC
1783  parameters[numberParameters++]=
1784    CbcOrClpParam("maxN!odes","Maximum number of nodes to do",
1785                  0,2147483647,MAXNODES);
1786  parameters[numberParameters-1].setLonghelp
1787    (
1788     "This is a repeatable way to limit search.  Normally using time is easier \
1789but then the results may not be repeatable."
1790     ); 
1791  parameters[numberParameters++]=
1792    CbcOrClpParam("maxS!olutions","Maximum number of solutions to get",
1793                  1,2147483647,MAXSOLS);
1794  parameters[numberParameters-1].setLonghelp
1795    (
1796     "You may want to stop after (say) two solutions or an hour."
1797     ); 
1798#endif
1799  parameters[numberParameters++]=
1800    CbcOrClpParam("min!imize","Set optimization direction to minimize",
1801                  MINIMIZE,7);
1802  parameters[numberParameters-1].setLonghelp
1803    (
1804     "The default is minimize - use 'maximize' for maximization.\n\
1805This should only be necessary if you have previously set maximization \
1806You can also use the parameters 'direction minimize'."
1807     );
1808#ifdef COIN_HAS_CBC
1809  parameters[numberParameters++]=
1810    CbcOrClpParam("mipO!ptions","Dubious options for mip",
1811                  0,COIN_INT_MAX,MIPOPTIONS,false);
1812  parameters[numberParameters++]=
1813    CbcOrClpParam("more!MipOptions","More dubious options for mip",
1814                  -1,COIN_INT_MAX,MOREMIPOPTIONS,false);
1815  parameters[numberParameters++]=
1816    CbcOrClpParam("mixed!IntegerRoundingCuts","Whether to use Mixed Integer Rounding cuts",
1817                  "off",MIXEDCUTS);
1818  parameters[numberParameters-1].append("on");
1819  parameters[numberParameters-1].append("root");
1820  parameters[numberParameters-1].append("ifmove");
1821  parameters[numberParameters-1].append("forceOn");
1822  parameters[numberParameters-1].setLonghelp
1823    (
1824     "This switches on mixed integer rounding cuts (either at root or in entire tree) \
1825See branchAndCut for information on options."
1826     ); 
1827#endif
1828  parameters[numberParameters++]=
1829    CbcOrClpParam("mess!ages","Controls if Clpnnnn is printed",
1830                  "off",MESSAGES);
1831  parameters[numberParameters-1].append("on");
1832  parameters[numberParameters-1].setLonghelp
1833    ("The default behavior is to put out messages such as:\n\
1834   Clp0005 2261  Objective 109.024 Primal infeas 944413 (758)\n\
1835but this program turns this off to make it look more friendly.  It can be useful\
1836 to turn them back on if you want to be able to 'grep' for particular messages or if\
1837 you intend to override the behavior of a particular message."
1838     );
1839#ifdef COIN_HAS_CBC
1840  parameters[numberParameters++]=
1841    CbcOrClpParam("miniT!ree","Size of fast mini tree",
1842                  0,COIN_INT_MAX,NUMBERMINI,false);
1843  parameters[numberParameters-1].setLonghelp
1844    (
1845     "The idea is that I can do a small tree fast. \
1846This is a first try and will hopefully become more sophisticated."
1847     ); 
1848  parameters[numberParameters++]=
1849    CbcOrClpParam("miplib","Do some of miplib test set",
1850                  MIPLIB,3);
1851#endif
1852#ifdef COIN_HAS_CLP
1853  parameters[numberParameters++]=
1854    CbcOrClpParam("netlib","Solve entire netlib test set",
1855                  NETLIB_EITHER,3);
1856  parameters[numberParameters-1].setLonghelp
1857    (
1858     "This exercises the unit test for clp and then solves the netlib test set using dual or primal.\
1859The user can set options before e.g. clp -presolve off -netlib"
1860     ); 
1861#ifdef REAL_BARRIER
1862  parameters[numberParameters++]=
1863    CbcOrClpParam("netlibB!arrier","Solve entire netlib test set with barrier",
1864                  NETLIB_BARRIER,3);
1865  parameters[numberParameters-1].setLonghelp
1866    (
1867     "This exercises the unit test for clp and then solves the netlib test set using barrier.\
1868The user can set options before e.g. clp -kkt on -netlib"
1869     ); 
1870#endif
1871  parameters[numberParameters++]=
1872    CbcOrClpParam("netlibD!ual","Solve entire netlib test set (dual)",
1873                  NETLIB_DUAL,3);
1874  parameters[numberParameters-1].setLonghelp
1875    (
1876     "This exercises the unit test for clp and then solves the netlib test set using dual.\
1877The user can set options before e.g. clp -presolve off -netlib"
1878     ); 
1879  parameters[numberParameters++]=
1880    CbcOrClpParam("netlibP!rimal","Solve entire netlib test set (primal)",
1881                  NETLIB_PRIMAL,3);
1882  parameters[numberParameters-1].setLonghelp
1883    (
1884     "This exercises the unit test for clp and then solves the netlib test set using primal.\
1885The user can set options before e.g. clp -presolve off -netlibp"
1886     ); 
1887  parameters[numberParameters++]=
1888    CbcOrClpParam("netlibT!une","Solve entire netlib test set with 'best' algorithm",
1889                  NETLIB_TUNE,3);
1890  parameters[numberParameters-1].setLonghelp
1891    (
1892     "This exercises the unit test for clp and then solves the netlib test set using whatever \
1893works best.  I know this is cheating but it also stresses the code better by doing a \
1894mixture of stuff.  The best algorithm was chosen on a Linux ThinkPad using native cholesky \
1895with University of Florida ordering."
1896     ); 
1897  parameters[numberParameters++]=
1898    CbcOrClpParam("network","Tries to make network matrix",
1899                  NETWORK,7,false);
1900  parameters[numberParameters-1].setLonghelp
1901    (
1902     "Clp will go faster if the matrix can be converted to a network.  The matrix\
1903 operations may be a bit faster with more efficient storage, but the main advantage\
1904 comes from using a network factorization.  It will probably not be as fast as a \
1905specialized network code."
1906     ); 
1907#ifdef COIN_HAS_CBC
1908  parameters[numberParameters++]=
1909    CbcOrClpParam("node!Strategy","What strategy to use to select nodes",
1910                  "fewest",NODESTRATEGY);
1911  parameters[numberParameters-1].append("depth");
1912  parameters[numberParameters-1].append("upfewest");
1913  parameters[numberParameters-1].append("downfewest");
1914  parameters[numberParameters-1].append("updepth");
1915  parameters[numberParameters-1].append("downdepth");
1916  parameters[numberParameters-1].setLonghelp
1917    (
1918     "Normally before a solution the code will choose node with fewest infeasibilities. \
1919You can choose depth as the criterion.  You can also say if up or down branch must \
1920be done first (the up down choice will carry on after solution)."
1921     ); 
1922  parameters[numberParameters++]=
1923    CbcOrClpParam("numberA!nalyze","Number of analysis iterations",
1924                  -COIN_INT_MAX,COIN_INT_MAX,NUMBERANALYZE,false);
1925  parameters[numberParameters-1].setLonghelp
1926    (
1927     "This says how many iterations to spend at root node analyzing problem. \
1928This is a first try and will hopefully become more sophisticated."
1929     ); 
1930#endif
1931  parameters[numberParameters++]=
1932    CbcOrClpParam("objective!Scale","Scale factor to apply to objective",
1933                  -1.0e20,1.0e20,OBJSCALE,false);
1934  parameters[numberParameters-1].setLonghelp
1935    (
1936     "If the objective function has some very large values, you may wish to scale them\
1937 internally by this amount.  It can also be set by autoscale.  It is applied after scaling"
1938     ); 
1939  parameters[numberParameters-1].setDoubleValue(1.0);
1940#endif
1941#ifdef COIN_HAS_CBC
1942  parameters[numberParameters++]=
1943    CbcOrClpParam("outDup!licates","takes duplicate rows etc out of integer model",
1944                  OUTDUPROWS,7,false);
1945#endif
1946  parameters[numberParameters++]=
1947    CbcOrClpParam("output!Format","Which output format to use",
1948                  1,6,OUTPUTFORMAT);
1949  parameters[numberParameters-1].setLonghelp
1950    (
1951     "Normally export will be done using normal representation for numbers and two values\
1952 per line.  You may want to do just one per line (for grep or suchlike) and you may wish\
1953 to save with absolute accuracy using a coded version of the IEEE value. A value of 2 is normal.\
1954 otherwise odd values gives one value per line, even two.  Values 1,2 give normal format, 3,4\
1955 gives greater precision, while 5,6 give IEEE values.  When used for exporting a basis 1 does not save \
1956values, 2 saves values, 3 with greater accuracy and 4 in IEEE."
1957     );
1958#ifdef COIN_HAS_CBC
1959  parameters[numberParameters++]=
1960    CbcOrClpParam("passC!uts","Number of cut passes at root node",
1961                  -999999,999999,CUTPASS);
1962  parameters[numberParameters-1].setLonghelp
1963    (
1964     "The default is 100 passes if less than 500 columns, 100 passes (but \
1965stop if drop small if less than 5000 columns, 20 otherwise"
1966     ); 
1967  parameters[numberParameters++]=
1968    CbcOrClpParam("passF!easibilityPump","How many passes in feasibility pump",
1969                  0,10000,FPUMPITS);
1970  parameters[numberParameters-1].setLonghelp
1971    (
1972     "This fine tunes Feasibility Pump by doing more or fewer passes."
1973     ); 
1974  parameters[numberParameters-1].setIntValue(20);
1975#endif
1976#ifdef COIN_HAS_CLP
1977  parameters[numberParameters++]=
1978    CbcOrClpParam("passP!resolve","How many passes in presolve",
1979                  -200,100,PRESOLVEPASS,false);
1980  parameters[numberParameters-1].setLonghelp
1981    (
1982     "Normally Presolve does 5 passes but you may want to do less to make it\
1983 more lightweight or do more if improvements are still being made.  As Presolve will return\
1984 if nothing is being taken out, you should not normally need to use this fine tuning."
1985     );
1986#endif
1987#ifdef COIN_HAS_CBC
1988  parameters[numberParameters++]=
1989    CbcOrClpParam("passT!reeCuts","Number of cut passes in tree",
1990                  -999999,999999,CUTPASSINTREE);
1991  parameters[numberParameters-1].setLonghelp
1992    (
1993     "The default is one pass"
1994     ); 
1995#endif
1996#ifdef COIN_HAS_CLP
1997  parameters[numberParameters++]=
1998    CbcOrClpParam("pertV!alue","Method of perturbation",
1999                  -5000,102,PERTVALUE,false);
2000  parameters[numberParameters++]=
2001    CbcOrClpParam("perturb!ation","Whether to perturb problem",
2002                  "on",PERTURBATION);
2003  parameters[numberParameters-1].append("off");
2004  parameters[numberParameters-1].setLonghelp
2005    (
2006     "Perturbation helps to stop cycling, but Clp uses other measures for this.\
2007  However large problems and especially ones with unit elements and unit rhs or costs\
2008 benefit from perturbation.  Normally Clp tries to be intelligent, but you can switch this off.\
2009  The Clp library has this off by default.  This program has it on by default."
2010     ); 
2011  parameters[numberParameters++]=
2012    CbcOrClpParam("PFI","Whether to use Product Form of Inverse in simplex",
2013                  "off",PFI,7,false);
2014  parameters[numberParameters-1].append("on");
2015  parameters[numberParameters-1].setLonghelp
2016    (
2017     "By default clp uses Forrest-Tomlin L-U update.  If you are masochistic you can switch it off."
2018     ); 
2019  parameters[numberParameters++]=
2020    CbcOrClpParam("plus!Minus","Tries to make +- 1 matrix",
2021                  PLUSMINUS,7,false);
2022  parameters[numberParameters-1].setLonghelp
2023    (
2024     "Clp will go slightly faster if the matrix can be converted so that the elements are\
2025 not stored and are known to be unit.  The main advantage is memory use.  Clp may automatically\
2026 see if it can convert the problem so you should not need to use this."
2027     ); 
2028  parameters[numberParameters++]=
2029    CbcOrClpParam("pO!ptions","Dubious print options",
2030                  0,COIN_INT_MAX,PRINTOPTIONS,false);
2031  parameters[numberParameters-1].setIntValue(0);
2032  parameters[numberParameters-1].setLonghelp
2033    (
2034     "If this is > 0 then presolve will give more information and branch and cut will give statistics"
2035     ); 
2036  parameters[numberParameters++]=
2037    CbcOrClpParam("preO!pt","Presolve options",
2038                  0,COIN_INT_MAX,PRESOLVEOPTIONS,false);
2039#endif
2040  parameters[numberParameters++]=
2041    CbcOrClpParam("presolve","Whether to presolve problem",
2042                  "on",PRESOLVE);
2043  parameters[numberParameters-1].append("off");
2044  parameters[numberParameters-1].append("more");
2045  parameters[numberParameters-1].append("file");
2046  parameters[numberParameters-1].setLonghelp
2047    (
2048     "Presolve analyzes the model to find such things as redundant equations, equations\
2049 which fix some variables, equations which can be transformed into bounds etc etc.  For the\
2050 initial solve of any problem this is worth doing unless you know that it will have no effect.  \
2051on will normally do 5 passes while using 'more' will do 10.  If the problem is very large you may need \
2052to write the original to file using 'file'."
2053     ); 
2054#ifdef COIN_HAS_CBC
2055  parameters[numberParameters++]=
2056    CbcOrClpParam("preprocess","Whether to use integer preprocessing",
2057                  "off",PREPROCESS);
2058  parameters[numberParameters-1].append("on");
2059  parameters[numberParameters-1].append("save");
2060  parameters[numberParameters-1].append("equal");
2061  parameters[numberParameters-1].append("sos");
2062  parameters[numberParameters-1].append("trysos");
2063  parameters[numberParameters-1].append("equalall");
2064  parameters[numberParameters-1].append("strategy");
2065  parameters[numberParameters-1].setLonghelp
2066    (
2067     "This tries to reduce size of model in a similar way to presolve and \
2068it also tries to strengthen the model - this can be very useful and is worth trying. \
2069 Save option saves on file presolved.mps.  equal will turn <= cliques into \
2070==.  sos will create sos sets if all 0-1 in sets (well one extra is allowed) \
2071and no overlaps.  trysos is same but allows any number extra.  equalall will turn all \
2072valid inequalities into equalities with integer slacks.  strategy is as \
2073on but uses CbcStrategy."
2074     ); 
2075#endif
2076#ifdef COIN_HAS_CLP
2077  parameters[numberParameters++]=
2078    CbcOrClpParam("preT!olerance","Tolerance to use in presolve",
2079                  1.0e-20,1.0e12,PRESOLVETOLERANCE);
2080  parameters[numberParameters-1].setLonghelp
2081    (
2082     "The default is 1.0e-8 - you may wish to try 1.0e-7 if presolve says the problem is \
2083infeasible and you have awkward numbers and you are sure the problem is really feasible."
2084     ); 
2085  parameters[numberParameters++]=
2086    CbcOrClpParam("primalP!ivot","Primal pivot choice algorithm",
2087                  "auto!matic",PRIMALPIVOT);
2088  parameters[numberParameters-1].append("exa!ct");
2089  parameters[numberParameters-1].append("dant!zig");
2090  parameters[numberParameters-1].append("part!ial");
2091  parameters[numberParameters-1].append("steep!est");
2092  parameters[numberParameters-1].append("change");
2093  parameters[numberParameters-1].append("sprint");
2094  parameters[numberParameters-1].setLonghelp
2095    (
2096     "Clp can use any pivot selection algorithm which the user codes as long as it\
2097 implements the features in the abstract pivot base class.  The Dantzig method is implemented\
2098 to show a simple method but its use is deprecated.  Exact devex is the method of choice and there\
2099 are two variants which keep all weights updated but only scan a subset each iteration.\
2100 Partial switches this on while change initially does dantzig until the factorization\
2101 becomes denser.  This is still a work in progress."
2102     ); 
2103  parameters[numberParameters++]=
2104    CbcOrClpParam("primalS!implex","Do primal simplex algorithm",
2105                  PRIMALSIMPLEX);
2106  parameters[numberParameters-1].setLonghelp
2107    (
2108     "This command solves the current model using the primal algorithm.\
2109  The default is to use exact devex.\
2110 The time and iterations may be affected by settings such as presolve, scaling, crash\
2111 and also by column selection  method, infeasibility weight and dual and primal tolerances."
2112     );
2113#endif
2114  parameters[numberParameters++]=
2115    CbcOrClpParam("primalT!olerance","For an optimal solution \
2116no primal infeasibility may exceed this value",
2117                  1.0e-20,1.0e12,PRIMALTOLERANCE);
2118  parameters[numberParameters-1].setLonghelp
2119    (
2120     "Normally the default tolerance is fine, but you may want to increase it a\
2121 bit if a primal run seems to be having a hard time"
2122     ); 
2123#ifdef COIN_HAS_CLP
2124  parameters[numberParameters++]=
2125    CbcOrClpParam("primalW!eight","Initially algorithm acts as if it \
2126costs this much to be infeasible",
2127                  1.0e-20,1.0e20,PRIMALWEIGHT);
2128  parameters[numberParameters-1].setLonghelp
2129    (
2130     "The primal algorithm in Clp is a single phase algorithm as opposed to a two phase\
2131 algorithm where you first get feasible then optimal.  So Clp is minimizing this weight times\
2132 the sum of primal infeasibilities plus the true objective function (in minimization sense).\
2133  Too high a value may mean more iterations, while too low a bound means\
2134 the code may go all the way and then have to increase the weight in order to get feasible.\
2135  OSL had a heuristic to\
2136 adjust bounds, maybe we need that here."
2137     ); 
2138#endif
2139  parameters[numberParameters++]=
2140    CbcOrClpParam("printi!ngOptions","Print options",
2141                  "normal",INTPRINT,3);
2142  parameters[numberParameters-1].append("integer");
2143  parameters[numberParameters-1].append("special");
2144  parameters[numberParameters-1].append("rows");
2145  parameters[numberParameters-1].append("all");
2146  parameters[numberParameters-1].setLonghelp
2147    (
2148     "This changes the amount and format of printing a solution:\nnormal - nonzero column variables \n\
2149integer - nonzero integer column variables\n\
2150special - in format suitable for OsiRowCutDebugger\n\
2151rows - nonzero column variables and row activities\n\
2152all - all column variables and row activities.\n\
2153\nFor non-integer problems 'integer' and 'special' act like 'normal'.  \
2154Also see printMask for controlling output."
2155     ); 
2156  parameters[numberParameters++]=
2157    CbcOrClpParam("printM!ask","Control printing of solution on a  mask",
2158                  PRINTMASK,3);
2159  parameters[numberParameters-1].setLonghelp
2160    (
2161     "If set then only those names which match mask are printed in a solution. \
2162'?' matches any character and '*' matches any set of characters. \
2163 The default is '' i.e. unset so all variables are printed. \
2164This is only active if model has names."
2165     ); 
2166#ifdef COIN_HAS_CBC
2167  parameters[numberParameters++]=
2168    CbcOrClpParam("prio!rityIn","Import priorities etc from file",
2169                  PRIORITYIN,3);
2170  parameters[numberParameters-1].setLonghelp
2171    (
2172     "This will read a file with priorities from the given file name.  It will use the default\
2173 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2174 is initialized to '', i.e. it must be set.  This can not read from compressed files. \
2175File is in csv format with allowed headings - name, number, priority, direction, up, down, solution.  Exactly one of\
2176 name and number must be given."
2177     ); 
2178  parameters[numberParameters++]=
2179    CbcOrClpParam("probing!Cuts","Whether to use Probing cuts",
2180                  "off",PROBINGCUTS);
2181  parameters[numberParameters-1].append("on");
2182  parameters[numberParameters-1].append("root");
2183  parameters[numberParameters-1].append("ifmove");
2184  parameters[numberParameters-1].append("forceOn");
2185  parameters[numberParameters-1].append("forceOnBut");
2186  parameters[numberParameters-1].append("forceOnStrong");
2187  parameters[numberParameters-1].append("forceOnButStrong");
2188  parameters[numberParameters-1].setLonghelp
2189    (
2190     "This switches on probing cuts (either at root or in entire tree) \
2191See branchAndCut for information on options. \
2192but strong options do more probing"
2193     ); 
2194  parameters[numberParameters++]=
2195    CbcOrClpParam("pumpT!une","Dubious ideas for feasibility pump",
2196                  0,100000000,FPUMPTUNE);
2197  parameters[numberParameters-1].setLonghelp
2198    (
2199     "This fine tunes Feasibility Pump \n\
2200\t>=1000000 use as accumulate switch\n\
2201\t>=1000 use index+1 as number of large loops\n\
2202\t>=100 use 0.05 objvalue as increment\n\
2203\t>=10 use +0.1 objvalue for cutoff (add)\n\
2204\t1 == fix ints at bounds, 2 fix all integral ints, 3 and continuous at bounds"
2205     ); 
2206  parameters[numberParameters-1].setIntValue(0);
2207#endif
2208  parameters[numberParameters++]=
2209    CbcOrClpParam("quit","Stops clp execution",
2210                  EXIT);
2211  parameters[numberParameters-1].setLonghelp
2212    (
2213     "This stops the execution of Clp, end, exit, quit and stop are synonyms"
2214     ); 
2215#ifdef COIN_HAS_CBC
2216  parameters[numberParameters++]=
2217    CbcOrClpParam("ratio!Gap","Stop when gap between best possible and \
2218best less than this fraction of larger of two",
2219                  0.0,1.0e20,GAPRATIO);
2220  parameters[numberParameters-1].setDoubleValue(0.0);
2221  parameters[numberParameters-1].setLonghelp
2222    (
2223     "If the gap between best solution and best possible solution is less than this fraction \
2224of the objective value at the root node then the search will terminate.  See 'allowableGap' for a \
2225way of using absolute value rather than fraction."
2226     ); 
2227#endif
2228#ifdef COIN_HAS_CLP
2229  parameters[numberParameters++]=
2230    CbcOrClpParam("reallyO!bjectiveScale","Scale factor to apply to objective in place",
2231                  -1.0e20,1.0e20,OBJSCALE2,false);
2232  parameters[numberParameters-1].setLonghelp
2233    (
2234     "You can set this to -1.0 to test maximization or other to stress code"
2235     ); 
2236  parameters[numberParameters-1].setDoubleValue(1.0);
2237  parameters[numberParameters++]=
2238    CbcOrClpParam("reallyS!cale","Scales model in place",
2239                  REALLY_SCALE,7,false);
2240#endif
2241#ifdef COIN_HAS_CBC
2242    parameters[numberParameters++]=
2243      CbcOrClpParam("reduce!AndSplitCuts","Whether to use Reduce-and-Split cuts",
2244              "off",REDSPLITCUTS);
2245    parameters[numberParameters-1].append("on");
2246    parameters[numberParameters-1].append("root");
2247    parameters[numberParameters-1].append("ifmove");
2248    parameters[numberParameters-1].append("forceOn");
2249    parameters[numberParameters-1].setLonghelp
2250    (
2251     "This switches on reduce and split  cuts (either at root or in entire tree) \
2252See branchAndCut for information on options."
2253     ); 
2254  parameters[numberParameters++]=
2255    CbcOrClpParam("residual!CapacityCuts","Whether to use Residual Capacity cuts",
2256                  "off",RESIDCUTS);
2257  parameters[numberParameters-1].append("on");
2258  parameters[numberParameters-1].append("root");
2259  parameters[numberParameters-1].append("ifmove");
2260  parameters[numberParameters-1].append("forceOn");
2261  parameters[numberParameters-1].setLonghelp
2262    (
2263     "Residual capacity cuts. \
2264See branchAndCut for information on options."
2265     ); 
2266#endif
2267#ifdef COIN_HAS_CLP
2268  parameters[numberParameters++]=
2269    CbcOrClpParam("restore!Model","Restore model from binary file",
2270                  RESTORE);
2271  parameters[numberParameters-1].setLonghelp
2272    (
2273     "This reads data save by saveModel from the given file.  It will use the default\
2274 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2275 is initialized to 'default.prob'."
2276     ); 
2277  parameters[numberParameters++]=
2278    CbcOrClpParam("reverse","Reverses sign of objective",
2279                  REVERSE,7,false);
2280  parameters[numberParameters-1].setLonghelp
2281    (
2282     "Useful for testing if maximization works correctly"
2283     ); 
2284  parameters[numberParameters++]=
2285    CbcOrClpParam("rhs!Scale","Scale factor to apply to rhs and bounds",
2286                  -1.0e20,1.0e20,RHSSCALE,false);
2287  parameters[numberParameters-1].setLonghelp
2288    (
2289     "If the rhs or bounds have some very large meaningful values, you may wish to scale them\
2290 internally by this amount.  It can also be set by autoscale"
2291     ); 
2292  parameters[numberParameters-1].setDoubleValue(1.0);
2293#endif
2294#ifdef COIN_HAS_CBC
2295  parameters[numberParameters++]=
2296      CbcOrClpParam("Rins","Whether to try Relaxed Induced Neighborhood Search",
2297                    "off",RINS);
2298    parameters[numberParameters-1].append("on");
2299  parameters[numberParameters-1].setLonghelp
2300    (
2301     "This switches on Relaxed induced neighborhood Search."
2302     ); 
2303  parameters[numberParameters++]=
2304    CbcOrClpParam("round!ingHeuristic","Whether to use Rounding heuristic",
2305                  "off",ROUNDING);
2306  parameters[numberParameters-1].append("on");
2307  parameters[numberParameters-1].setLonghelp
2308    (
2309     "This switches on a simple (but effective) rounding heuristic at each node of tree."
2310     ); 
2311#endif
2312  parameters[numberParameters++]=
2313    CbcOrClpParam("saveM!odel","Save model to binary file",
2314                  SAVE);
2315  parameters[numberParameters-1].setLonghelp
2316    (
2317     "This will save the problem to the given file name for future use\
2318 by restoreModel.  It will use the default\
2319 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2320 is initialized to 'default.prob'."
2321     ); 
2322  parameters[numberParameters++]=
2323    CbcOrClpParam("saveS!olution","saves solution to file",
2324                  SAVESOL);
2325  parameters[numberParameters-1].setLonghelp
2326    (
2327     "This will write a binary solution file to the given file name.  It will use the default\
2328 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2329 is initialized to 'solution.file'.  To read the file use fread(int) twice to pick up number of rows \
2330and columns, then fread(double) to pick up objective value, then pick up row activities, row duals, column \
2331activities and reduced costs - see bottom of CbcOrClpParam.cpp for code that reads or writes file."
2332     ); 
2333  parameters[numberParameters++]=
2334    CbcOrClpParam("scal!ing","Whether to scale problem",
2335                  "off",SCALING);
2336  parameters[numberParameters-1].append("equi!librium");
2337  parameters[numberParameters-1].append("geo!metric");
2338  parameters[numberParameters-1].append("auto!matic");
2339  parameters[numberParameters-1].setLonghelp
2340    (
2341     "Scaling can help in solving problems which might otherwise fail because of lack of\
2342 accuracy.  It can also reduce the number of iterations.  It is not applied if the range\
2343 of elements is small.  When unscaled it is possible that there may be small primal and/or\
2344 infeasibilities."
2345     ); 
2346  parameters[numberParameters-1].setCurrentOption(3); // say auto
2347#ifndef COIN_HAS_CBC
2348  parameters[numberParameters++]=
2349    CbcOrClpParam("sec!onds","Maximum seconds",
2350                  -1.0,1.0e12,TIMELIMIT);
2351  parameters[numberParameters-1].setLonghelp
2352    (
2353     "After this many seconds clp will act as if maximum iterations had been reached \
2354(if value >=0).  \
2355In this program it is really only useful for testing but the library function\n\
2356      \tsetMaximumSeconds(value)\n can be useful."
2357     );
2358#else
2359  parameters[numberParameters++]=
2360    CbcOrClpParam("sec!onds","maximum seconds",
2361                  -1.0,1.0e12,TIMELIMIT_BAB);
2362  parameters[numberParameters-1].setLonghelp
2363    (
2364     "After this many seconds coin solver will act as if maximum nodes had been reached."
2365     );
2366#endif
2367  parameters[numberParameters++]=
2368    CbcOrClpParam("sleep","for debug",
2369                  DUMMY,7,false);
2370  parameters[numberParameters-1].setLonghelp
2371    (
2372     "If passed to solver fom ampl, then ampl will wait so that you can copy .nl file for debug."
2373     ); 
2374#ifdef COIN_HAS_CLP
2375  parameters[numberParameters++]=
2376    CbcOrClpParam("slp!Value","Number of slp passes before primal",
2377                  -1,50000,SLPVALUE,false);
2378  parameters[numberParameters-1].setLonghelp
2379    (
2380     "If you are solving a quadratic problem using primal then it may be helpful to do some \
2381sequential Lps to get a good approximate solution."
2382     ); 
2383#endif
2384  parameters[numberParameters++]=
2385    CbcOrClpParam("solu!tion","Prints solution to file",
2386                  SOLUTION);
2387  parameters[numberParameters-1].setLonghelp
2388    (
2389     "This will write a primitive solution file to the given file name.  It will use the default\
2390 directory given by 'directory'.  A name of '$' will use the previous value for the name.  This\
2391 is initialized to 'stdout'.  The amount of output can be varied using printi!ngOptions or printMask."
2392     ); 
2393#ifdef COIN_HAS_CLP
2394#ifdef COIN_HAS_CBC
2395  parameters[numberParameters++]=
2396    CbcOrClpParam("solv!e","Solve problem",
2397                  BAB);
2398  parameters[numberParameters-1].setLonghelp
2399    (
2400     "If there are no integer variables then this just solves LP.  If there are integer variables \
2401this does branch and cut."
2402     ); 
2403  parameters[numberParameters++]=
2404    CbcOrClpParam("sos!Options","Whether to use SOS from AMPL",
2405                  "off",SOS);
2406  parameters[numberParameters-1].append("on");
2407  parameters[numberParameters-1].setCurrentOption("on");
2408  parameters[numberParameters-1].setLonghelp
2409    (
2410     "Normally if AMPL says there are SOS variables they should be used, but sometime sthey should\
2411 be turned off - this does so."
2412     ); 
2413  parameters[numberParameters++]=
2414    CbcOrClpParam("slog!Level","Level of detail in Solver output",
2415                  -1,63,SOLVERLOGLEVEL);
2416  parameters[numberParameters-1].setLonghelp
2417    (
2418     "If 0 then there should be no output in normal circumstances.  1 is probably the best\
2419 value for most uses, while 2 and 3 give more information."
2420     );
2421#else
2422  // allow solve as synonym for dual
2423  parameters[numberParameters++]=
2424    CbcOrClpParam("solv!e","Solve problem using dual simplex",
2425                  BAB);
2426  parameters[numberParameters-1].setLonghelp
2427    (
2428     "Just so can use solve for clp as well as in cbc"
2429     ); 
2430#endif
2431#endif
2432#ifdef COIN_HAS_CLP
2433  parameters[numberParameters++]=
2434    CbcOrClpParam("spars!eFactor","Whether factorization treated as sparse",
2435                  "on",SPARSEFACTOR,7,false);
2436  parameters[numberParameters-1].append("off");
2437  parameters[numberParameters++]=
2438    CbcOrClpParam("special!Options","Dubious options for Simplex - see ClpSimplex.hpp",
2439                  0,COIN_INT_MAX,SPECIALOPTIONS,false);
2440  parameters[numberParameters++]=
2441    CbcOrClpParam("sprint!Crash","Whether to try sprint crash",
2442                  -1,5000000,SPRINT);
2443  parameters[numberParameters-1].setLonghelp
2444    (
2445     "For long and thin problems this program may solve a series of small problems\
2446 created by taking a subset of the columns.  I introduced the idea as 'Sprint' after\
2447 an LP code of that name of the 60's which tried the same tactic (not totally successfully).\
2448  Cplex calls it 'sifting'.  -1 is automatic choice, 0 is off, n is number of passes"
2449     ); 
2450  parameters[numberParameters++]=
2451    CbcOrClpParam("stat!istics","Print some statistics",
2452                  STATISTICS);
2453  parameters[numberParameters-1].setLonghelp
2454    (
2455     "This command prints some statistics for the current model.\
2456 If log level >1 then more is printed.\
2457 These are for presolved model if presolve on (and unscaled)."
2458     );
2459#endif
2460  parameters[numberParameters++]=
2461    CbcOrClpParam("stop","Stops clp execution",
2462                  EXIT);
2463  parameters[numberParameters-1].setLonghelp
2464    (
2465     "This stops the execution of Clp, end, exit, quit and stop are synonyms"
2466     ); 
2467#ifdef COIN_HAS_CBC
2468  parameters[numberParameters++]=
2469    CbcOrClpParam("strengthen","Create strengthened problem",
2470                  STRENGTHEN,3);
2471  parameters[numberParameters-1].setLonghelp
2472    (
2473     "This creates a new problem by applying the root node cuts.  All tight constraints \
2474will be in resulting problem"
2475     ); 
2476  parameters[numberParameters++]=
2477    CbcOrClpParam("strong!Branching","Number of variables to look at in strong branching",
2478                  0,999999,STRONGBRANCHING);
2479  parameters[numberParameters-1].setLonghelp
2480    (
2481     "In order to decide which variable to branch on, the code will choose up to this number \
2482of unsatisfied variables to do mini up and down branches on.  Then the most effective one is chosen. \
2483If a variable is branched on many times then the previous average up and down costs may be used - \
2484see number before trust."
2485     ); 
2486#endif
2487#ifdef COIN_HAS_CLP
2488  parameters[numberParameters++]=
2489    CbcOrClpParam("subs!titution","How long a column to substitute for in presolve",
2490                  0,10000,SUBSTITUTION,false);
2491  parameters[numberParameters-1].setLonghelp
2492    (
2493     "Normally Presolve gets rid of 'free' variables when there are no more than 3 \
2494 variables in column.  If you increase this the number of rows may decrease but number of \
2495 elements may increase."
2496     ); 
2497#endif
2498#ifdef COIN_HAS_CBC
2499  parameters[numberParameters++]=
2500    CbcOrClpParam("testO!si","Test OsiObject stuff",
2501                  -1,COIN_INT_MAX,TESTOSI,false);
2502#endif
2503#ifdef CBC_THREAD
2504  parameters[numberParameters++]=
2505    CbcOrClpParam("thread!s","Number of threads to try and use",
2506                  -100,10000,THREADS,false);
2507  parameters[numberParameters-1].setLonghelp
2508    (
2509     "To use multiple threads, set threads to number wanted.  It may be better \
2510to use one or two more than number of cpus available.  If 100+n then n threads and \
2511threads used in sub-trees, if 200+n use threads for root cuts, 300+n - both."
2512     ); 
2513#endif
2514#ifdef COIN_HAS_CBC
2515  parameters[numberParameters++]=
2516    CbcOrClpParam("tighten!Factor","Tighten bounds using this times largest \
2517activity at continuous solution",
2518                  1.0e-3,1.0e20,TIGHTENFACTOR,false);
2519  parameters[numberParameters-1].setLonghelp
2520    (
2521     "This sleazy trick can help on some problems."
2522     ); 
2523#endif
2524#ifdef COIN_HAS_CLP
2525  parameters[numberParameters++]=
2526    CbcOrClpParam("tightLP","Poor person's preSolve for now",
2527                  TIGHTEN,7,false);
2528#endif
2529#ifdef COIN_HAS_CBC
2530  parameters[numberParameters++]=
2531    CbcOrClpParam("trust!PseudoCosts","Number of branches before we trust pseudocosts",
2532                  -1,2000000,NUMBERBEFORE);
2533  parameters[numberParameters-1].setLonghelp
2534    (
2535     "Using strong branching computes pseudo-costs.  After this many times for a variable we just \
2536trust the pseudo costs and do not do any more strong branching."
2537     ); 
2538#endif
2539#ifdef COIN_HAS_CBC
2540  parameters[numberParameters++]=
2541    CbcOrClpParam("tune!PreProcess","Dubious tuning parameters",
2542                  0,20000000,PROCESSTUNE,false);
2543  parameters[numberParameters-1].setLonghelp
2544    (
2545     "For making equality cliques this is minimumsize.  Also for adding \
2546integer slacks.  May be used for more later \
2547If <1000 that is what it does.  If <1000000 - numberPasses is (value/1000)-1 and tune is tune %1000. \
2548If >= 1000000! - numberPasses is (value/1000000)-1 and tune is tune %1000000.  In this case if tune is now still >=10000 \
2549numberPassesPerInnerLoop is changed from 10 to (tune-10000)-1 and tune becomes tune % 10000!!!!! - happy? - \
2550so to keep normal limit on cliques of 5, do 3 major passes (include presolves) but only doing one tightening pass per major pass - \
2551you would use 3010005 (I think)"
2552     ); 
2553  parameters[numberParameters++]=
2554    CbcOrClpParam("two!MirCuts","Whether to use Two phase Mixed Integer Rounding cuts",
2555                  "off",TWOMIRCUTS);
2556  parameters[numberParameters-1].append("on");
2557  parameters[numberParameters-1].append("root");
2558  parameters[numberParameters-1].append("ifmove");
2559  parameters[numberParameters-1].append("forceOn");
2560  parameters[numberParameters-1].setLonghelp
2561    (
2562     "This switches on two phase mixed integer rounding  cuts (either at root or in entire tree) \
2563See branchAndCut for information on options."
2564     ); 
2565#endif
2566  parameters[numberParameters++]=
2567    CbcOrClpParam("unitTest","Do unit test",
2568                  UNITTEST,3);
2569  parameters[numberParameters-1].setLonghelp
2570    (
2571     "This exercises the unit test for clp"
2572     ); 
2573  parameters[numberParameters++]=
2574    CbcOrClpParam("userClp","Hand coded Clp stuff",
2575                  USERCLP);
2576  parameters[numberParameters-1].setLonghelp
2577    (
2578     "There are times e.g. when using AMPL interface when you may wish to do something unusual.  \
2579Look for USERCLP in main driver and modify sample code."
2580     ); 
2581#ifdef COIN_HAS_CBC
2582  parameters[numberParameters++]=
2583    CbcOrClpParam("userCbc","Hand coded Cbc stuff",
2584                  USERCBC);
2585  parameters[numberParameters-1].setLonghelp
2586    (
2587     "There are times e.g. when using AMPL interface when you may wish to do something unusual.  \
2588Look for USERCBC in main driver and modify sample code."
2589     ); 
2590#endif
2591  parameters[numberParameters++]=
2592    CbcOrClpParam("vector","Whether to use vector? Form of matrix in simplex",
2593                  "off",VECTOR,7,false);
2594  parameters[numberParameters-1].append("on");
2595  parameters[numberParameters-1].setLonghelp
2596    (
2597     "If this is on and ClpPackedMatrix uses extra column copy in odd format."
2598     ); 
2599  parameters[numberParameters++]=
2600    CbcOrClpParam("verbose","Switches on longer help on single ?",
2601                  0,15,VERBOSE,false);
2602  parameters[numberParameters-1].setLonghelp
2603    (
2604     "Set to 1 to get short help with ? list, 2 to get long help, 3 for both.  (add 4 to just get ampl ones)."
2605     ); 
2606  parameters[numberParameters-1].setIntValue(0);
2607  assert(numberParameters<CBCMAXPARAMETERS);
2608}
2609// Given a parameter type - returns its number in list
2610int whichParam (CbcOrClpParameterType name, 
2611                int numberParameters, CbcOrClpParam *const parameters)
2612{
2613  int i;
2614  for (i=0;i<numberParameters;i++) {
2615    if (parameters[i].type()==name)
2616      break;
2617  }
2618  assert (i<numberParameters);
2619  return i;
2620}
2621#ifdef COIN_HAS_CLP
2622// Dump a solution to file
2623void saveSolution(const ClpSimplex * lpSolver,std::string fileName)
2624{
2625  FILE * fp=fopen(fileName.c_str(),"wb");
2626  if (fp) {
2627    int numberRows=lpSolver->numberRows();
2628    int numberColumns=lpSolver->numberColumns();
2629    double objectiveValue = lpSolver->objectiveValue();
2630    fwrite(&numberRows,sizeof(int),1,fp);
2631    fwrite(&numberColumns,sizeof(int),1,fp);
2632    fwrite(&objectiveValue,sizeof(double),1,fp);
2633    double * dualRowSolution = lpSolver->dualRowSolution();
2634    double * primalRowSolution = lpSolver->primalRowSolution();
2635    fwrite(primalRowSolution,sizeof(double),numberRows,fp);
2636    fwrite(dualRowSolution,sizeof(double),numberRows,fp);
2637    double * dualColumnSolution = lpSolver->dualColumnSolution();
2638    double * primalColumnSolution = lpSolver->primalColumnSolution();
2639    fwrite(primalColumnSolution,sizeof(double),numberColumns,fp);
2640    fwrite(dualColumnSolution,sizeof(double),numberColumns,fp);
2641    fclose(fp);
2642  } else {
2643    std::cout<<"Unable to open file "<<fileName<<std::endl;
2644  }
2645}
2646/* Restore a solution from file.
2647   mode 0 normal, 1 swap rows and columns and primal and dual
2648   if 2 set then also change signs
2649*/
2650void restoreSolution(ClpSimplex * lpSolver,std::string fileName,int mode)
2651{
2652  FILE * fp=fopen(fileName.c_str(),"rb");
2653  if (fp) {
2654    int numberRows=lpSolver->numberRows();
2655    int numberColumns=lpSolver->numberColumns();
2656    int numberRowsFile;
2657    int numberColumnsFile;
2658    double objectiveValue;
2659    fread(&numberRowsFile,sizeof(int),1,fp);
2660    fread(&numberColumnsFile,sizeof(int),1,fp);
2661    fread(&objectiveValue,sizeof(double),1,fp);
2662    double * dualRowSolution = lpSolver->dualRowSolution();
2663    double * primalRowSolution = lpSolver->primalRowSolution();
2664    double * dualColumnSolution = lpSolver->dualColumnSolution();
2665    double * primalColumnSolution = lpSolver->primalColumnSolution();
2666    if (mode) {
2667      // swap
2668      int k=numberRows;
2669      numberRows=numberColumns;
2670      numberColumns=k;
2671      double * temp;
2672      temp = dualRowSolution;
2673      dualRowSolution = primalColumnSolution;
2674      primalColumnSolution=temp;
2675      temp = dualColumnSolution;
2676      dualColumnSolution = primalRowSolution;
2677      primalRowSolution=temp;
2678    }
2679    if (numberRows!=numberRowsFile||numberColumns!=numberColumnsFile) {
2680      std::cout<<"Mismatch on rows and/or columns"<<std::endl;
2681    } else {
2682      lpSolver->setObjectiveValue(objectiveValue);
2683      fread(primalRowSolution,sizeof(double),numberRows,fp);
2684      fread(dualRowSolution,sizeof(double),numberRows,fp);
2685      fread(primalColumnSolution,sizeof(double),numberColumns,fp);
2686      fread(dualColumnSolution,sizeof(double),numberColumns,fp);
2687      if (mode==3) {
2688        int i;
2689        for (i=0;i<numberRows;i++) {
2690          primalRowSolution[i] = -primalRowSolution[i];
2691          dualRowSolution[i] = -dualRowSolution[i];
2692        }
2693        for (i=0;i<numberColumns;i++) {
2694          primalColumnSolution[i] = -primalColumnSolution[i];
2695          dualColumnSolution[i] = -dualColumnSolution[i];
2696        }
2697      }
2698    }
2699    fclose(fp);
2700  } else {
2701    std::cout<<"Unable to open file "<<fileName<<std::endl;
2702  }
2703}
2704#endif
Note: See TracBrowser for help on using the repository browser.