13sys.path.append(
'../common/')
23 adding the variables and constraints to the model
24 @ingroup PYTHON1THREAD_SQUARE2
30 self.
x0 = self.addVariable(-co.Conopt.Infinity, co.Conopt.Infinity, 0.0)
31 self.
x1 = self.addVariable(-co.Conopt.Infinity, co.Conopt.Infinity, 0.0)
34 self.
cons1 = self.addConstraint(
35 co.ConstraintType_Eq, 10.0, [self.
x0, self.
x1], [1, 1], [0, 0]
37 self.
cons2 = self.addConstraint(
38 co.ConstraintType_Eq, 0.0, [self.
x0, self.
x1], [0, 0], [1, 1]
40 self.
cons3 = self.addConstraint(
41 co.ConstraintType_LtEq, 9.0, [self.
x0, self.
x1], [0, 0], [1, 1]
46 @copydoc conopt.ModelData.evaluateNonlinearTerm
47 @ingroup PYTHON1THREAD_SQUARE2
50 if rowno == self.
cons1:
53 elif rowno == self.
cons2:
54 g = x[self.
x0] - x[self.
x1]
56 elif rowno == self.
cons3:
57 g = x[self.
x0] + x[self.
x1]
63 @copydoc conopt.ModelData.evaluateNonlinearJacobian
64 @ingroup PYTHON1THREAD_SQUARE2
67 if rowno == self.
cons1:
70 elif rowno == self.
cons2:
74 elif rowno == self.
cons3:
81if __name__ ==
'__main__':
82 name = os.path.basename(__file__)[:-3]
84 conopt = co.Conopt(name)
85 model = SquareModelData()
90 conopt.loadModel(model)
91 conopt.setMessageHandler(msghdlr)
97 license_int_1 = os.environ.get(
'CONOPT_LICENSE_INT_1',
None)
98 license_int_2 = os.environ.get(
'CONOPT_LICENSE_INT_2',
None)
99 license_int_3 = os.environ.get(
'CONOPT_LICENSE_INT_3',
None)
100 license_text = os.environ.get(
'CONOPT_LICENSE_TEXT',
None)
102 license_int_1
is not None
103 and license_int_2
is not None
104 and license_int_3
is not None
105 and license_text
is not None
114 coi_error = conopt.solve()
117 std.python_log(conopt,
'Errors encountered during solution')
120 (conopt.solutionStatus() != 1)
121 or (conopt.modelStatus() < 4)
122 or (conopt.modelStatus() > 5)
125 conopt,
'Solver or Model status not as expected (1,4) or (1,5)'
131 std.python_log(conopt,
'Successful Solve')
buildModel(self)
adding the variables and constraints to the model
evaluateNonlinearTerm(self, x, rowno, ignerr, thread)
callback method for evaluating the nonlinear terms in a given row
evaluateNonlinearJacobian(self, x, rowno, jacnum, ignerr, thread)
callback method for evaluating the jacobian for the nonlinear terms in a given row