13sys.path.append(
'../common/')
27 adding the variables and constraints to the model
28 @ingroup PYTHON1THREAD_TUTORIALk
31 self.
varl = self.addVariable(0.1, co.Conopt.Infinity, 0.5)
32 self.
vark = self.addVariable(4.0, 4.0, 4.0)
33 self.
varinp = self.addVariable(0.1, co.Conopt.Infinity, 0.5)
34 self.
varout = self.addVariable(0.0, co.Conopt.Infinity)
35 self.
varp = self.addVariable(0.0, co.Conopt.Infinity)
39 co.ConstraintType_Free,
53 co.ConstraintType_Eq, 4.0, [self.
varout, self.
varp], [1, 2], [0, 0]
57 self.setObjectiveElement(co.ObjectiveElement_Constraint, 0)
60 self.setOptimizationSense(co.Sense_Maximize)
64 @copydoc conopt.ModelData.evaluateNonlinearTerm
65 @ingroup PYTHON1THREAD_TUTORIALk
78 self.
Al * pow(L, (-self.
Rho))
79 + self.
Ak * pow(K, (-self.
Rho))
80 + self.
Ainp * pow(Inp, (-self.
Rho))
82 hold2 = pow(hold1, (-1.0 / self.
Rho))
90 @copydoc conopt.ModelData.evaluateNonlinearJacobian
92 NOTE: The jacobian is returned as a list of length jacnum. In this
93 example, the returned list is constructed using `append`. It is also
94 possible to initially create a list of length jacnum containing only 0s,
95 then update the values by the variable indices.
97 @ingroup PYTHON1THREAD_TUTORIALk
111 self.
Al * pow(L, (-self.
Rho))
112 + self.
Ak * pow(K, (-self.
Rho))
113 + self.
Ainp * pow(Inp, (-self.
Rho))
115 hold2 = pow(hold1, (-1.0 / self.
Rho))
116 hold3 = hold2 / hold1
118 jac.append(hold3 * self.
Al * pow(L, (-self.
Rho - 1.0)))
119 jac.append(hold3 * self.
Ak * pow(K, (-self.
Rho - 1.0)))
120 jac.append(hold3 * self.
Ainp * pow(Inp, (-self.
Rho - 1.0)))
125if __name__ ==
'__main__':
126 name = os.path.basename(__file__)[:-3]
128 conopt = co.Conopt(name)
129 model = TutModelData()
134 conopt.loadModel(model)
135 conopt.setMessageHandler(msghdlr)
138 license_int_1 = os.environ.get(
'CONOPT_LICENSE_INT_1',
None)
139 license_int_2 = os.environ.get(
'CONOPT_LICENSE_INT_2',
None)
140 license_int_3 = os.environ.get(
'CONOPT_LICENSE_INT_3',
None)
141 license_text = os.environ.get(
'CONOPT_LICENSE_TEXT',
None)
143 license_int_1
is not None
144 and license_int_2
is not None
145 and license_int_3
is not None
146 and license_text
is not None
155 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