13sys.path.append(
'../common/')
30 adding the variables and constraints to the model
31 @ingroup PYTHON1THREAD_TUTORIAL2
40 self.
addConstraint(pyconopt.ConstraintType_Free, -0.1, [0, 1, 2, 3],
41 [-1, -1, 0, 0], [0, 0, 1, 1])
42 self.
addConstraint(pyconopt.ConstraintType_Eq, 0.0, [0, 1, 2], [0, 0, -1],
44 self.
addConstraint(pyconopt.ConstraintType_Eq, 4.0, [2, 3], [1, 2],
59 @ingroup PYTHON1THREAD_TUTORIAL2
70 hold1 = (self.
Al*pow(L,(-self.
Rho)) + self.
Ak*pow(self.
K,(-self.
Rho)) + self.
Ainp*pow(Inp,(-self.
Rho)))
71 hold2 = pow(hold1,( -1./self.
Rho ))
79 @ingroup PYTHON1THREAD_TUTORIAL2
91 hold1 = (self.
Al*pow(L,(-self.
Rho)) + self.
Ak*pow(self.
K,(-self.
Rho)) + self.
Ainp*pow(Inp,(-self.
Rho)))
92 hold2 = pow(hold1,( -1./self.
Rho ))
95 jac.append(hold3 * self.
Al * pow(L ,(-self.
Rho-1.)))
96 jac.append(hold3 * self.
Ainp * pow(Inp,(-self.
Rho-1.)))
103 @ingroup PYTHON1THREAD_TUTORIAL2
105 numhessian = len(hessianrow)
106 hessian = [0
for i
in range(numhessian)]
114 hold1 = (self.
Al*pow(L,-self.
Rho) + self.
Ak*pow(self.
K,-self.
Rho) + self.
Ainp*pow(Inp,-self.
Rho))
115 hold2 = pow( hold1,-1.0/self.
Rho)
116 hold3 = hold2 / hold1
118 hold4 = hold3 / hold1 * (-1.0/self.
Rho-1.0)
120 hessian[0] = hold4 * (-self.
Rho) * pow(self.
Al*pow(L,-self.
Rho-1.0),2) \
121 + hold3 * self.
Al * (-self.
Rho-1.0)*pow(L,-self.
Rho-2.0)
122 hessian[1] = hold4 * (-self.
Rho) * (self.
Al*pow(L,-self.
Rho-1.0)) * \
123 (self.
Ainp*pow(Inp,-self.
Rho-1.0))
124 hessian[2] = hold4 * (-self.
Rho) * \
125 pow(self.
Ainp*pow(Inp,-self.
Rho-1.0),2) + \
126 hold3 * self.
Ainp * (-self.
Rho-1.0)*pow(Inp,-self.
Rho-2.0)
128 for i
in range(numhessian):
129 hessian[i] = hessian[i] * u[1]
133if __name__ ==
"__main__":
134 name = os.path.basename(__file__)[:-3]
137 model = TutModelData()
142 conopt.loadModel(model)
143 conopt.setMessageHandler(msghdlr)
146 license_int_1 = os.environ.get(
'LICENSE_INT_1',
None)
147 license_int_2 = os.environ.get(
'LICENSE_INT_2',
None)
148 license_int_3 = os.environ.get(
'LICENSE_INT_3',
None)
149 license_text = os.environ.get(
'LICENSE_TEXT',
None)
150 if license_int_1
is not None and license_int_2
is not None \
151 and license_int_3
is not None and license_text
is not None:
152 conopt.setLicense(int(license_int_1), int(license_int_2),
153 int(license_int_3), license_text)
155 coi_error = conopt.solve()
setOptimizationSense(self, sense)
sets the optimisation direction.
setObjectiveElement(self, elem, elemindex)
sets the index for the objective variable or constraint
setSDLagrangianStructure(self, rownum, colnum)
sets the structure of the second derivatives of the Lagrangian
addVariable(self, *args)
Overload 1: adds a variable to the model.
addConstraint(self, *args)
Overload 1: adds a constraint to the problem.
A class that can be extended to build and solve a model using Conopt.
static int checkSolve(String name, int model_status, int solution_status, double objective, double expected_objective, double tol)
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
evaluateSDLagrangian(self, x, u, hessianrow, hessiancol)
Computes and returns the numerical values of the Lagrangian of the Hessian.