| 1 |
// (C) Copyright International Business Machines Corporation and |
| 2 |
// Carnegie Mellon University 2004, 2007 |
| 3 |
// |
| 4 |
// All Rights Reserved. |
| 5 |
// This code is published under the Eclipse Public License. |
| 6 |
// |
| 7 |
// Authors : |
| 8 |
// Pierre Bonami, Carnegie Mellon University, |
| 9 |
// Andreas Waechter, International Business Machines Corporation |
| 10 |
// |
| 11 |
// Date : 12/01/2004 |
| 12 |
|
| 13 |
#ifndef BonminAmplInterface_H |
| 14 |
#define BonminAmplInterface_H |
| 15 |
#include "BonOsiTMINLPInterface.hpp" |
| 16 |
#include "BonAmplTMINLP.hpp" |
| 17 |
|
| 18 |
class BM_lp; |
| 19 |
namespace Bonmin |
| 20 |
{ |
| 21 |
/** Class for providing an Osi interface to Ipopt with an ampl nl file as input. */ |
| 22 |
class AmplInterface: public OsiTMINLPInterface |
| 23 |
{ |
| 24 |
public: |
| 25 |
/** Default constructor */ |
| 26 |
/** Default constructor only available for Bonmin's friends and child classes.*/ |
| 27 |
AmplInterface(); |
| 28 |
/**@name Methods to input a problem */ |
| 29 |
//@{ |
| 30 |
virtual void readAmplNlFile(char **& argv, Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions, |
| 31 |
Ipopt::SmartPtr<Ipopt::OptionsList> options, |
| 32 |
Ipopt::SmartPtr<Ipopt::Journalist> journalist, |
| 33 |
std::string* nl_file_content = NULL); |
| 34 |
//@} |
| 35 |
/** Copy constructor */ |
| 36 |
AmplInterface(const AmplInterface &other); |
| 37 |
/// Clone |
| 38 |
virtual OsiSolverInterface * clone(bool CopyData = true); |
| 39 |
|
| 40 |
/// Destructor |
| 41 |
virtual ~AmplInterface(); |
| 42 |
|
| 43 |
|
| 44 |
/** Fast access to AmplTMINLP */ |
| 45 |
const AmplTMINLP * amplModel() const |
| 46 |
{ |
| 47 |
return GetRawPtr(amplTminlp_); |
| 48 |
} |
| 49 |
/** To set some application specific defaults. */ |
| 50 |
virtual void setAppDefaultOptions(Ipopt::SmartPtr<Ipopt::OptionsList> Options); |
| 51 |
|
| 52 |
protected: |
| 53 |
/** Read variables and row names in .col and .row files.*/ |
| 54 |
void readNames() ; |
| 55 |
|
| 56 |
/** TMINLP problem (the original problem usually an AmplTMINLP).*/ |
| 57 |
Ipopt::SmartPtr<Bonmin::AmplTMINLP> amplTminlp_; |
| 58 |
|
| 59 |
private: |
| 60 |
/** Write the ampl solution file or write a bonmin one?*/ |
| 61 |
int writeAmplSolFile_; |
| 62 |
}; |
| 63 |
} |
| 64 |
#endif |