13sys.path.append(
'../common/')
23 adding the variables and constraints to the model
24 @ingroup PYTHON1THREAD_SQUARE
29 self.
x0 = self.addVariable(-co.Conopt.Infinity, co.Conopt.Infinity, 0.0)
30 self.
x1 = self.addVariable(-co.Conopt.Infinity, co.Conopt.Infinity, 0.0)
33 self.
cons1 = self.addConstraint(
34 co.ConstraintType_Eq, 10.0, [self.
x0, self.
x1], [1, 1], [0, 0]
36 self.
cons2 = self.addConstraint(
37 co.ConstraintType_Eq, 0.0, [self.
x0, self.
x1], [0, 0], [1, 1]
42 @copydoc conopt.ModelData.evaluateNonlinearTerm
43 @ingroup PYTHON1THREAD_SQUARE
46 if rowno == self.
cons1:
49 elif rowno == self.
cons2:
50 g = x[self.
x0] - x[self.
x1]
56 @copydoc conopt.ModelData.evaluateNonlinearJacobian
57 @ingroup PYTHON1THREAD_SQUARE
60 if rowno == self.
cons1:
63 elif rowno == self.
cons2:
70if __name__ ==
'__main__':
71 name = os.path.basename(__file__)[:-3]
73 conopt = co.Conopt(name)
74 model = SquareModelData()
79 conopt.loadModel(model)
80 conopt.setMessageHandler(msghdlr)
86 license_int_1 = os.environ.get(
'CONOPT_LICENSE_INT_1',
None)
87 license_int_2 = os.environ.get(
'CONOPT_LICENSE_INT_2',
None)
88 license_int_3 = os.environ.get(
'CONOPT_LICENSE_INT_3',
None)
89 license_text = os.environ.get(
'CONOPT_LICENSE_TEXT',
None)
91 license_int_1
is not None
92 and license_int_2
is not None
93 and license_int_3
is not None
94 and license_text
is not None
103 coi_error = conopt.solve()
106 std.python_log(conopt,
'Errors encountered during solution')
107 elif (conopt.modelStatus() != 16)
or (conopt.solutionStatus() != 1):
108 std.python_log(conopt,
'Solver or Model status not as expected (1,16)')
113 std.python_log(conopt,
'Successful Solve')
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
evaluateNonlinearTerm(self, x, rowno, ignerr, thread)
callback method for evaluating the nonlinear terms in a given row