13sys.path.append(
'../common/')
33 adding the variables and constraints to the model
34 @ingroup PYTHON1THREAD_QP2
37 for i
in range(self.
NN):
38 self.addVariable(0.0, co.Conopt.Infinity)
42 varidx = list(range(self.
NN))
45 self.addConstraint(co.ConstraintType_Free, 0.0, varidx, zeros, ones)
48 self.addConstraint(co.ConstraintType_Eq, 1.0, varidx, ones, zeros)
51 self.setObjectiveElement(co.ObjectiveElement_Constraint, 0)
54 self.setOptimizationSense(co.Sense_Minimize)
57 self.setSDEvaluationType(co.SDEvaluationType_Constraint)
61 @copydoc conopt.ModelData.evaluateNonlinearTerm
62 @ingroup PYTHON1THREAD_QP2
71 for i, q
in enumerate(self.
Qdiag)
76 (x[i + 1] - self.
target[i + 1]) * q * (x[i] - self.
target[i])
85 @copydoc conopt.ModelData.evaluateNonlinearJacobian
86 @ingroup PYTHON1THREAD_QP2
90 for i
in range(self.
NN):
100 @copydoc conopt.ModelData.evaluateDirectionalSD
101 @ingroup PYTHON1THREAD_QP2
103 dirsd = [0] * self.
NN
104 for i
in range(self.
NN):
105 dirsd[i] += self.
Qdiag[i] * dx[i]
113if __name__ ==
'__main__':
114 name = os.path.basename(__file__)[:-3]
116 conopt = co.Conopt(name)
117 model = QPModelData()
122 conopt.loadModel(model)
123 conopt.setMessageHandler(msghdlr)
126 license_int_1 = os.environ.get(
'CONOPT_LICENSE_INT_1',
None)
127 license_int_2 = os.environ.get(
'CONOPT_LICENSE_INT_2',
None)
128 license_int_3 = os.environ.get(
'CONOPT_LICENSE_INT_3',
None)
129 license_text = os.environ.get(
'CONOPT_LICENSE_TEXT',
None)
131 license_int_1
is not None
132 and license_int_2
is not None
133 and license_int_3
is not None
134 and license_text
is not None
143 coi_error = conopt.solve()
static int checkSolve(String name, int model_status, int solution_status, double objective, double expected_objective, double tol)
evaluateNonlinearTerm(self, x, rowno, ignerr, thread)
callback method for evaluating the nonlinear terms in a given row
buildModel(self)
adding the variables and constraints to the model
evaluateNonlinearJacobian(self, x, rowno, jacnum, ignerr, thread)
callback method for evaluating the jacobian for the nonlinear terms in a given row
evaluateDirectionalSD(self, x, dx, rowno, jacnum, thread)
computes the directional second derivative for a single constraint