CONOPT
Loading...
Searching...
No Matches
conopticpp.h
Go to the documentation of this file.
1
7
8
9#ifndef _CONOPTICPP_H_
10#define _CONOPTICPP_H_
11
12#include <string>
13#include <array>
14
15#include "defines.h"
16
17#include "conoptic.h"
18#include "modeldata.h"
19#include "messagehandler.h"
20#include "solution.h"
21#include "status.h"
22
27class ConoptCpp {
28public:
35 COI_API ConoptCpp(std::string modelName = "conopt-model");
36
41 COI_API ~ConoptCpp();
42
49 COI_API int solve();
50
54 COI_API int checkModelAndParameters();
55
63 COI_API coiHandle_t controlVector();
64
70 COI_API void printStatus();
71
77 COI_API std::string getName();
78
79 /* model data methods */
80
91 COI_API void loadModel(ConoptModelData& modeldata);
92
93 /* optimisation status methods */
94
99 COI_API int modelStatus();
100
106 COI_API int solutionStatus();
107
113 COI_API int iterations();
114
120 COI_API double objectiveValue();
121
122 /* solution methods */
123
129 COI_API const std::vector<double>& getVariableValues();
130
136 COI_API const std::vector<double>& getVariableMarginals();
137
143 COI_API const std::vector<int>& getVariableBasisStatus();
144
150 COI_API const std::vector<int>& getVariableStatus();
151
157 COI_API const std::vector<double>& getConstraintValues();
158
164 COI_API const std::vector<double>& getConstraintMarginals();
165
171 COI_API const std::vector<int>& getConstraintBasisStatus();
172
178 COI_API const std::vector<int>& getConstraintStatus();
179
180 /* message handler methods */
181
192 COI_API void setMessageHandler(ConoptMessageHandler& msghandler);
193
201 COI_API int sendMessage(std::string msg);
202
216 COI_API void setVerbosityLevel(int verblevel);
217
218#if 0
219
220
221 virtual int Option(int ncall, double* rval, int* ival, int* lval, char* name, void* usrmem)
222 {
223 return 0;
224 }
225
227 virtual int TriOrd(int mode, int type, int status, int rowno, int colno, int inf, double value, double resid,
228 void* usrmem)
229 {
230 return 0;
231 }
232
233
234#endif
235
243 static COI_API std::array<int, 3> version();
244
252 COI_API int debugFV(int debugfv);
253
261 COI_API int squareModel(int square);
262
269 COI_API int setLicense(int licint1, int licint2, int licint3, std::string licstring);
270
277 COI_API int setItLim(int itlim);
278
285 COI_API int setErrLim(int errlim);
286
293 COI_API int fVincLin(int fvinclin);
294
301 COI_API int fVforAll(int fvforall);
302
309 COI_API int setMaxSup(int maxsup);
310
317 COI_API int allowEmptyRow(int emptyrow);
318
325 COI_API int allowEmptyCol(int emptycol);
326
333 COI_API int debug2D(int debug2d);
334
341 COI_API int disCont(int discont);
342
343
350 COI_API int clearM(int clearm);
351
358 COI_API int setResLim(double reslim);
359
366 COI_API int setMaxHeap(double maxheap);
367
374 COI_API int setThreadS(int threads);
375
382 COI_API int setThreadF(int threadf);
383
390 COI_API int setThread2D(int thread2d);
391
398 COI_API int setThreadC(int threadc);
399
410 COI_API int getMaxThreads();
411
417 COI_API double getMaxHeapUsed();
418
424 COI_API int getRangeErrors();
425
426private:
427 std::string name;
428
429 int coi_error_;
430 coiHandle_t cntVect_;
431
432 ConoptModelData* modeldata_;
433 ConoptSolution solution_;
434 ConoptStatus status_;
435
436 /* message handling objects. We create a default message handler, which can be replaced by the user if necessary */
437 ConoptMessageHandler defmessage_;
438 ConoptMessageHandler* message_;
439};
440
441#endif // _CONOPTICPP_H_
The message handler class.
The Model Data class.
Definition modeldata.h:129
program fvforall
Main program. A simple setup and call of CONOPT.
Definition fvforall.f90:14
program fvinclin
Main program. A simple setup and call of CONOPT.
Definition fvinclin.f90:14
COI_API int sendMessage(std::string msg)
sends a message to the message handler
COI_API void setMessageHandler(ConoptMessageHandler &msghandler)
sets the message handler to the user supplied handler.
COI_API void setVerbosityLevel(int verblevel)
sets the verbosity level for messaging
COI_API void loadModel(ConoptModelData &modeldata)
loads the model and stores the pointer in the interface
COI_API ~ConoptCpp()
COI_API ConoptCpp(std::string modelName="conopt-model")
COI_API int setErrLim(int errlim)
define the Error Limit.
COI_API int squareModel(int square)
square models.
COI_API int fVforAll(int fvforall)
call the FDEval for all constraints, including linear constraints.
COI_API int setThread2D(int thread2d)
number of threads allowed for simultaneous 2DDir calls.
COI_API int allowEmptyCol(int emptycol)
allow empty columns.
COI_API int setItLim(int itlim)
define the Iteration Limit.
COI_API int setThreadC(int threadc)
check for thread compatibility.
COI_API int clearM(int clearm)
ClearM.
COI_API int setThreadS(int threads)
number of threads allowed internally in CONOPT.
COI_API int setLicense(int licint1, int licint2, int licint3, std::string licstring)
define the License Information.
COI_API int setResLim(double reslim)
define resource limit.
COI_API int setMaxHeap(double maxheap)
define Limit on Heap Memory.
COI_API int setMaxSup(int maxsup)
limit on superbasics.
COI_API int debugFV(int debugfv)
turn Debugging of FDEval on and off.
COI_API int setThreadF(int threadf)
number of threads allowed for simultaneous FDEval calls.
COI_API int fVincLin(int fvinclin)
include the linear terms in function evaluations.
COI_API int disCont(int discont)
allow discontinuous functions and derivatives.
COI_API int debug2D(int debug2d)
turn debugging of 2nd derivatives on and off.
COI_API int allowEmptyRow(int emptyrow)
allow empty rows.
COI_API const std::vector< int > & getConstraintBasisStatus()
returns the constraint basis status
COI_API int modelStatus()
returns the model status
COI_API const std::vector< int > & getVariableBasisStatus()
returns the variable basis status
COI_API const std::vector< int > & getVariableStatus()
returns the variable status
COI_API const std::vector< double > & getConstraintMarginals()
returns the constraint marginals
COI_API int iterations()
returns the number of iterations
COI_API double objectiveValue()
returns the objective value
COI_API const std::vector< int > & getConstraintStatus()
returns the constraint status
COI_API int solutionStatus()
return the solution status
COI_API const std::vector< double > & getVariableValues()
returns the variable values
COI_API const std::vector< double > & getVariableMarginals()
returns the variable marginals
COI_API const std::vector< double > & getConstraintValues()
returns the constraint values
COI_API double getMaxHeapUsed()
After a model has been solved this method will return the amount of heap memory used.
static COI_API std::array< int, 3 > version()
returns the version number.
COI_API std::string getName()
returns the model name
COI_API void printStatus()
prints the status of the optimisation
COI_API coiHandle_t controlVector()
returns the control vector pointer.
COI_API int solve()
method for starting the solving process of CONOPT.
COI_API int getRangeErrors()
returns the range errors that were encountered.
COI_API int getMaxThreads()
returns the maximum number of threads that can be used by CONOPT.
The message handler class for the CONOPT C++ API.
The model data class for the CONOPT C++ API.
program square
Main program. A simple setup and call of CONOPT.
Definition square.f90:17