25 std::vector<double>
Q;
47 for (
int i = 0; i <
nvar; ++i)
76 for (
int i = 0; i <
nvar; ++i)
80 std::vector<int> varIdx(
nvar);
81 std::vector<double> ones(
nvar, 1.0);
82 std::vector<int> nlflags_free(
nvar, 1);
83 std::vector<int> nlflags_sum(
nvar, 0);
85 for (
int i = 0; i <
nvar; ++i)
111 int FDEval(
const double x[],
double *g,
double jac[],
int rowno,
const int jacnum[],
int mode,
112 int ignerr,
int *errcnt,
int numvar,
int numjac,
int thread)
override
117 if (mode == 1 || mode == 3)
120 for (
int k = 0; k <
nqnz; ++k)
127 sum += 2.0 * (x[i] -
Target[i]) * qi * (x[j] -
Target[j]);
133 if (mode == 2 || mode == 3)
135 for (
int i = 0; i < numvar; ++i)
138 for (
int k = 0; k <
nqnz; ++k)
143 jac[i] += qi * (x[i] -
Target[i]);
146 jac[i] += qi * (x[j] -
Target[j]);
147 jac[j] += qi * (x[i] -
Target[i]);
178 conopt.setMessageHandler(msghandler);
184 conopt.loadModel(modeldata);
186#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
187 std::string license = CONOPT_LICENSE_TEXT;
188 COI_Error +=
conopt.setLicense(CONOPT_LICENSE_INT_1, CONOPT_LICENSE_INT_2, CONOPT_LICENSE_INT_3, license);
194 "Skipping COI_Solve due to setup errors. COI_Error = " + std::to_string(
COI_Error));
200 conopt.sendMessage(
"After solving. COI_Error = " + std::to_string(
COI_Error));
201 if (
conopt.modelStatus() != 2 ||
conopt.solutionStatus() != 1)
203 else if (fabs(
conopt.objectiveValue() - 59978.0) > 0.001)
static constexpr double Infinity
std::vector< double > Target
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.
QP5_ModelData(int numvar)
the constructor for the QP instance model data.
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 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 cpp_log(Conopt &conopt, std::string msg, int code)
std::string getProgramName(char *execname)