13sys.path.append(
'../common/')
33 adding the variables and constraints to the model
34 @ingroup PYTHON1THREAD_QP1
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)
58 @copydoc conopt.ModelData.evaluateNonlinearTerm
59 @ingroup PYTHON1THREAD_QP1
68 for i, q
in enumerate(self.
Qdiag)
73 (x[i + 1] - self.
target[i + 1]) * q * (x[i] - self.
target[i])
82 @copydoc conopt.ModelData.evaluateNonlinearJacobian
83 @ingroup PYTHON1THREAD_QP1
87 for i
in range(self.
NN):
96if __name__ ==
'__main__':
97 name = os.path.basename(__file__)[:-3]
99 conopt = co.Conopt(name)
100 model = QPModelData()
105 conopt.loadModel(model)
106 conopt.setMessageHandler(msghdlr)
109 license_int_1 = os.environ.get(
'CONOPT_LICENSE_INT_1',
None)
110 license_int_2 = os.environ.get(
'CONOPT_LICENSE_INT_2',
None)
111 license_int_3 = os.environ.get(
'CONOPT_LICENSE_INT_3',
None)
112 license_text = os.environ.get(
'CONOPT_LICENSE_TEXT',
None)
114 license_int_1
is not None
115 and license_int_2
is not None
116 and license_int_3
is not None
117 and license_text
is not None
126 coi_error = conopt.solve()
static int checkSolve(String name, int model_status, int solution_status, double objective, double expected_objective, double tol)
evaluateNonlinearJacobian(self, x, rowno, jacnum, ignerr, thread)
callback method for evaluating the jacobian for the nonlinear terms in a given row
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