88 {-1, -1, 0, 0}, {0, 0, 1, 1});
94 ConoptConstraintType::Eq, 0.0, {
varl,
varinp,
varint}, {0, 0, -1}, {1, 1, 0});
120 int FDEval(
const double x[],
double *g,
double jac[],
int rowno,
const int jacnum[],
int mode,
121 int ignerr,
int *errcnt,
int numvar,
int numjac,
int thread)
override
150 if (mode == 1 || mode == 3)
155 if (mode == 2 || mode == 3)
170 if (mode == 1 || mode == 3)
175 if (mode == 2 || mode == 3)
192 if (mode == 1 || mode == 3)
193 *g = pow(Int, (-1.0 /
Rho));
197 if (mode == 2 || mode == 3)
199 jac[
varint] = (-1.0 /
Rho) * pow(Int, (-1.0 /
Rho - 1.0));
210 int SDLagrVal(
const double x[],
const double u[],
const int hsrw[],
const int hscl[],
211 double hsvl[],
int *nodrv,
int numvar,
int numcon,
int nhess)
override
230 hsvl[3] = (-1.0 /
Rho) * (-1.0 /
Rho - 1.0) * pow(x[
varint], -1.0 /
Rho - 2.0);
255 conopt.setMessageHandler(msghandler);
261 conopt.loadModel(modeldata);
263#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
264 std::string license = CONOPT_LICENSE_TEXT;
265 COI_Error +=
conopt.setLicense(CONOPT_LICENSE_INT_1, CONOPT_LICENSE_INT_2, CONOPT_LICENSE_INT_3, license);
270 conopt.sendMessage(
"Skipping COI_Solve due to setup errors. COI_Error = " + std::to_string(
COI_Error));
276 conopt.sendMessage(
"After solving. COI_Error = " + std::to_string(
COI_Error));
277 if (
conopt.modelStatus() != 2 ||
conopt.solutionStatus() != 1)
279 else if (fabs(
conopt.objectiveValue() - 0.572943) > 0.000001)
static constexpr double Infinity
CONOPT C++ interface header file. This is the main object for the CONOPT C++ interface.
int main(int argc, char **argv)
Main program. A simple setup and call of CONOPT.
void buildModel()
adds the variables and constraints for the problem
int FDEval(const double x[], double *g, double jac[], int rowno, const int jacnum[], int mode, int ignerr, int *errcnt, int numvar, int numjac, int thread) override
defines the nonlinearities of the model by returning numerical values.
int SDLagrVal(const double x[], const double u[], const int hsrw[], const int hscl[], double hsvl[], int *nodrv, int numvar, int numcon, int nhess) override
Computes and returns the numerical values of the Hessian.
int addVariable(double lower, double upper, double curr=0, int varstatus=-1)
adds a variable to the model. The non-zero coefficients are added later.
void setObjectiveElement(ConoptObjectiveElement elem, int elemindex)
sets the index for the objective variable or constraint
int addConstraint(ConoptConstraintType constype, double rhs, int slackstatus=-1)
adds a constraint to the problem. The non-zero coefficients are added later
void setOptimizationSense(ConoptSense sense)
sets the optimisation direction.
void setSDLagrangianStructure(const std::vector< int > &rownum, const std::vector< int > &colnum)
sets the structure of the second derivatives of the Lagrangian
void cpp_log(Conopt &conopt, std::string msg, int code)
std::string getProgramName(char *execname)