13sys.path.append(
'../common/')
28 adding the variables and constraints to the model
29 @ingroup PYTHON1THREAD_TUTORIAL
32 self.
varl = self.addVariable(0.1, co.Conopt.Infinity, 0.5)
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_TUTORIAL
77 self.
Al * pow(L, (-self.
Rho))
78 + self.
Ak * pow(self.
K, (-self.
Rho))
79 + self.
Ainp * pow(Inp, (-self.
Rho))
81 hold2 = pow(hold1, (-1.0 / self.
Rho))
89 @copydoc conopt.ModelData.evaluateNonlinearJacobian
91 NOTE: The jacobian is returned as a list of length jacnum. In this
92 example, the returned list is constructed using `append`. It is also
93 possible to initially create a list of length jacnum containing only 0s,
94 then update the values by the variable indices.
96 @ingroup PYTHON1THREAD_TUTORIAL
109 self.
Al * pow(L, (-self.
Rho))
110 + self.
Ak * pow(self.
K, (-self.
Rho))
111 + self.
Ainp * pow(Inp, (-self.
Rho))
113 hold2 = pow(hold1, (-1.0 / self.
Rho))
114 hold3 = hold2 / hold1
116 jac.append(hold3 * self.
Al * pow(L, (-self.
Rho - 1.0)))
117 jac.append(hold3 * self.
Ainp * pow(Inp, (-self.
Rho - 1.0)))
122if __name__ ==
'__main__':
123 name = os.path.basename(__file__)[:-3]
125 conopt = co.Conopt(name)
126 model = TutModelData()
131 conopt.loadModel(model)
132 conopt.setMessageHandler(msghdlr)
135 license_int_1 = os.environ.get(
'CONOPT_LICENSE_INT_1',
None)
136 license_int_2 = os.environ.get(
'CONOPT_LICENSE_INT_2',
None)
137 license_int_3 = os.environ.get(
'CONOPT_LICENSE_INT_3',
None)
138 license_text = os.environ.get(
'CONOPT_LICENSE_TEXT',
None)
140 license_int_1
is not None
141 and license_int_2
is not None
142 and license_int_3
is not None
143 and license_text
is not None
152 coi_error = conopt.solve()
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