13sys.path.append(
'../common/')
37 adding the variables and constraints to the model
38 @ingroup PYTHON1THREAD_TUTORIALI
41 self.
varl = self.addVariable(0.1, co.Conopt.Infinity, 0.5)
42 self.
varinp = self.addVariable(0.1, co.Conopt.Infinity, 0.5)
43 self.
varout = self.addVariable(0.0, co.Conopt.Infinity)
44 self.
varp = self.addVariable(0.0, co.Conopt.Infinity)
48 co.ConstraintType_Free,
62 co.ConstraintType_Eq, 4.0, [self.
varout, self.
varp], [1, 2], [0, 0]
66 self.setObjectiveElement(co.ObjectiveElement_Constraint, 0)
69 self.setOptimizationSense(co.Sense_Maximize)
73 @copydoc conopt.ModelData.initFDEvaluation
74 @ingroup PYTHON1THREAD_TUTORIALI
82 self.
Al * pow(self.
L, (-self.
Rho))
83 + self.
Ak * pow(self.
K, (-self.
Rho))
91 @copydoc conopt.ModelData.evaluateNonlinearTerm
92 @ingroup PYTHON1THREAD_TUTORIALI
104 @copydoc conopt.ModelData.evaluateNonlinearJacobian
106 NOTE: The jacobian is returned as a list of length jacnum. In this
107 example, the returned list is constructed using `append`. It is also
108 possible to initially create a list of length jacnum containing only 0s,
109 then update the values by the variable indices.
111 @ingroup PYTHON1THREAD_TUTORIALI
118 jac.append(self.
hold3 * self.
Al * pow(self.
L, (-self.
Rho - 1.0)))
124if __name__ ==
'__main__':
125 name = os.path.basename(__file__)[:-3]
127 conopt = co.Conopt(name)
128 model = TutModelData()
133 conopt.loadModel(model)
134 conopt.setMessageHandler(msghdlr)
137 license_int_1 = os.environ.get(
'CONOPT_LICENSE_INT_1',
None)
138 license_int_2 = os.environ.get(
'CONOPT_LICENSE_INT_2',
None)
139 license_int_3 = os.environ.get(
'CONOPT_LICENSE_INT_3',
None)
140 license_text = os.environ.get(
'CONOPT_LICENSE_TEXT',
None)
142 license_int_1
is not None
143 and license_int_2
is not None
144 and license_int_3
is not None
145 and license_text
is not None
154 coi_error = conopt.solve()
static int checkSolve(String name, int model_status, int solution_status, double objective, double expected_objective, double tol)
initFDEvaluation(self, x, rowlist, mode, numthread, ignerr)
callback method for initialising the first derivative evaluation.
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