15 public static void main(String argv[]) {
16 System.loadLibrary(
"conoptjni4");
18 String
name =
"tutorialk";
21 TutKModelData
model =
new TutKModelData();
31 int license_int_1 = Integer.parseInt(System.getenv(
"CONOPT_LICENSE_INT_1"));
32 int license_int_2 = Integer.parseInt(System.getenv(
"CONOPT_LICENSE_INT_2"));
33 int license_int_3 = Integer.parseInt(System.getenv(
"CONOPT_LICENSE_INT_3"));
34 String
license_text = System.getenv(
"CONOPT_LICENSE_TEXT");
38 }
catch (Exception e) {
39 System.out.println(
"Unable to set license: " + e.getMessage());
48 conopt.objectiveValue(), 0.572943, 0.000001);
72 public TutKModelData() {
78 private void setConstants() {
100 int[] index = {varl, varinp, varout, varp};
101 double[] value = {-1, -1, 0, 0};
102 int[] nlflag = {0, 0, 1, 1};
109 int[] index = {varl, vark, varinp, varout};
110 double[] value = {0, 0, 0, -1};
111 int[] nlflag = {1, 1, 1, 0};
117 int[] index = {varout, varp};
118 double[] value = {1, 2};
119 int[] nlflag = {0, 0};
137 double Inp = x[varinp];
138 double Out = x[varout];
142 if (rowno == consobj) {
145 else if (rowno == consprod) {
146 double hold1 = (Al * Math.pow(
L, (-Rho)) + Ak * Math.pow(
K, (-Rho)) + Ainp * Math.pow(
Inp, (-Rho)));
160 assert x.length == jac.length;
164 double Inp = x[varinp];
165 double Out = x[varout];
168 if (rowno == consobj) {
172 else if (rowno == consprod) {
173 double hold1 = (Al*Math.pow(
L,(-Rho)) + Ak*Math.pow(
K,(-Rho)) + Ainp*Math.pow(
Inp,(-Rho)));
177 jac[varl] =
hold3 * Al * Math.pow(
L, (-Rho - 1.));
178 jac[vark] =
hold3 * Ak * Math.pow(
K, (-Rho - 1.));
179 jac[varinp] =
hold3 * Ainp * Math.pow(
Inp, (-Rho - 1.));
static final ConstraintType Eq
static final ConstraintType Free
A class that can be extended to build and solve a model using Conopt.
static final ObjectiveElement Constraint
static final Sense Maximize
static int checkSolve(String name, int model_status, int solution_status, double objective, double expected_objective, double tol)
static void main(String argv[])
addConstraint(self, *args)
Overload 1: adds a constraint to the problem.
setObjectiveElement(self, elem, elemindex)
sets the index for the objective variable or constraint
addVariable(self, *args)
Overload 1: adds a variable to the model.
setOptimizationSense(self, sense)
sets the optimisation direction.
double evaluateNonlinearTerm(double[] x, int rowno, boolean ignerr, int thread)
callback method for evaluating the nonlinear terms in a given row
void evaluateNonlinearJacobian(double[] x, double[] jac, int rowno, int[] jacnum, boolean ignerr, int thread)
callback method for evaluating the jacobian for the nonlinear terms in a given row
void buildModel()
adds variables and constraints to the model