| 1 |
// (C) Copyright CNRS and others 2010 |
| 2 |
// All Rights Reserved. |
| 3 |
// This code is published under the Eclipse Public License. |
| 4 |
// |
| 5 |
// Authors : |
| 6 |
// Pierre Bonami, Université de la Méditérannée |
| 7 |
// Hassan Hijazi, Orange Labs |
| 8 |
// |
| 9 |
// Date : 05/22/2010 |
| 10 |
|
| 11 |
#ifndef RobotSetup_H |
| 12 |
#define RobotSetup_H |
| 13 |
#include "BonBonminSetup.hpp" |
| 14 |
#include "BonAmplSetup.hpp" |
| 15 |
namespace Bonmin |
| 16 |
{ |
| 17 |
/** algorithm setup. */ |
| 18 |
class RobotSetup : public BonminSetup |
| 19 |
{ |
| 20 |
public: |
| 21 |
/** Default constructor. */ |
| 22 |
RobotSetup(const CoinMessageHandler * handler = NULL); |
| 23 |
/** Copy constructor. */ |
| 24 |
RobotSetup(const RobotSetup & other); |
| 25 |
|
| 26 |
/** Copy but uses an other nlp.*/ |
| 27 |
RobotSetup(const RobotSetup &setup, |
| 28 |
OsiTMINLPInterface &nlp); |
| 29 |
|
| 30 |
/** Copy but uses another nlp and algorithm.*/ |
| 31 |
RobotSetup(const RobotSetup &setup, |
| 32 |
OsiTMINLPInterface &nlp, |
| 33 |
const std::string & prefix); |
| 34 |
/** virtual copy constructor. */ |
| 35 |
virtual BonminSetup * clone() const |
| 36 |
{ |
| 37 |
return new RobotSetup(*this); |
| 38 |
} |
| 39 |
/** Make a copy with solver replace by one passed .*/ |
| 40 |
// virtual BonminSetup *clone(OsiTMINLPInterface&nlp)const{ |
| 41 |
// return new RobotSetup(*this, nlp); |
| 42 |
// } |
| 43 |
/** Make a copy with solver replace by one passed .*/ |
| 44 |
RobotSetup *clone(OsiTMINLPInterface&nlp)const{ |
| 45 |
return new RobotSetup(*this, nlp); |
| 46 |
} |
| 47 |
/** Make a copy but take options with different prefix.*/ |
| 48 |
RobotSetup *clone(OsiTMINLPInterface &nlp, const std::string & prefix)const{ |
| 49 |
return new RobotSetup(*this, nlp, prefix); |
| 50 |
} |
| 51 |
virtual ~RobotSetup() |
| 52 |
{} |
| 53 |
/** @name Methods to instantiate: Registering and retrieving options and initializing everything. */ |
| 54 |
/** @{ */ |
| 55 |
/** Register all the options for this algorithm instance.*/ |
| 56 |
virtual void registerOptions(); |
| 57 |
/** @} */ |
| 58 |
/** Register all bonmin type executable options.*/ |
| 59 |
static void registerAllOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions); |
| 60 |
/** Initialize, read options and create appropriate bonmin setup.*/ |
| 61 |
void initialize(Ipopt::SmartPtr<TMINLP> tminlp, bool createContinuousSolver = true); |
| 62 |
/** Initialize, read options and create appropriate bonmin setup.*/ |
| 63 |
void initialize(const OsiTMINLPInterface& nlpSi, bool createContinuousSolver = true); |
| 64 |
|
| 65 |
/** Ampl initialization*/ |
| 66 |
void initialize(char **& argv) |
| 67 |
{ |
| 68 |
readOptionsFile(); |
| 69 |
/* Read the model.*/ |
| 70 |
Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(), options(), |
| 71 |
argv, NULL, "bonmin", NULL); |
| 72 |
mayPrintDoc(); |
| 73 |
initialize(Ipopt::GetRawPtr(model), true); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
protected: |
| 79 |
/** Add nway objects*/ |
| 80 |
void addNWays(); |
| 81 |
/** Initialize a branch-and-with robot nway.*/ |
| 82 |
void initializeRobot(); |
| 83 |
}; |
| 84 |
}/** end namespace Bonmin*/ |
| 85 |
|
| 86 |
#endif |
| 87 |
|