13sys.path.append(
'../common/')
30 adding the variables and constraints to the model
31 @ingroup PYTHON1THREAD_TUTORIAL2r
38 self.
varl = self.addVariable(0.1, co.Conopt.Infinity, initL)
39 self.
varinp = self.addVariable(0.1, co.Conopt.Infinity, initInp)
40 self.
varout = self.addVariable(0.0, co.Conopt.Infinity)
41 self.
varp = self.addVariable(0.0, co.Conopt.Infinity)
45 self.
Al * pow(initL, -self.
Rho)
46 + self.
Ak * pow(self.
K, -self.
Rho)
47 + self.
Ainp * pow(initInp, -self.
Rho),
52 co.ConstraintType_Free,
66 co.ConstraintType_Eq, 4.0, [self.
varout, self.
varp], [1, 2], [0, 0]
77 self.setObjectiveElement(co.ObjectiveElement_Constraint, 0)
80 self.setOptimizationSense(co.Sense_Maximize)
83 self.setSDLagrangianStructure([0, 1, 3, 4], [0, 1, 2, 4])
87 @copydoc conopt.ModelData.evaluateNonlinearTerm
88 @ingroup PYTHON1THREAD_TUTORIAL2r
101 self.
Al * pow(L, (-self.
Rho))
102 + self.
Ak * pow(self.
K, (-self.
Rho))
103 + self.
Ainp * pow(Inp, (-self.
Rho))
106 g = pow(Int, (-1.0 / self.
Rho))
112 @copydoc conopt.ModelData.evaluateNonlinearJacobian
114 NOTE: The jacobian is returned as a list of length jacnum. In this
115 example, the returned list is constructed using `append`. It is also
116 possible to initially create a list of length jacnum containing only 0s,
117 then update the values by the variable indices.
119 @ingroup PYTHON1THREAD_TUTORIAL2r
132 jac.append(self.
Al * (-self.
Rho) * pow(L, (-self.
Rho - 1.0)))
133 jac.append(self.
Ainp * (-self.
Rho) * pow(Inp, (-self.
Rho - 1.0)))
135 jac.append((-1.0 / self.
Rho) * pow(Int, (-1.0 / self.
Rho - 1.0)))
141 @copydoc conopt.ModelData.evaluateSDLagrangian
142 @ingroup PYTHON1THREAD_TUTORIAL2r
144 numhessian = len(hessianrow)
145 hessian = [0
for i
in range(numhessian)]
155 * pow(L, -self.
Rho - 2.0)
162 * pow(Inp, -self.
Rho - 2.0)
169 * (-1.0 / self.
Rho - 1.0)
170 * pow(x[self.
varint], -1.0 / self.
Rho - 2.0)
176if __name__ ==
'__main__':
177 name = os.path.basename(__file__)[:-3]
179 conopt = co.Conopt(name)
180 model = TutModelData()
185 conopt.loadModel(model)
186 conopt.setMessageHandler(msghdlr)
189 license_int_1 = os.environ.get(
'CONOPT_LICENSE_INT_1',
None)
190 license_int_2 = os.environ.get(
'CONOPT_LICENSE_INT_2',
None)
191 license_int_3 = os.environ.get(
'CONOPT_LICENSE_INT_3',
None)
192 license_text = os.environ.get(
'CONOPT_LICENSE_TEXT',
None)
194 license_int_1
is not None
195 and license_int_2
is not None
196 and license_int_3
is not None
197 and license_text
is not None
206 coi_error = conopt.solve()
static int checkSolve(String name, int model_status, int solution_status, double objective, double expected_objective, double tol)
buildModel(self)
adding the variables and constraints to the model
evaluateSDLagrangian(self, x, u, hessianrow, hessiancol)
Computes and returns the numerical values of the Lagrangian of the Hessian.
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