定义变量
IloNumVar[] x = cplex.numVarArray(3, 0.0, 100.0);//three continuous variables with range 0 to 100
定义表达式
IloNumExpr expr = cplex.sum(x[0],
cplex.prod(2.0, x[1]),
cplex.prod(3.0, x[2]));//x[0]+2x[1]+3x[2]
或者
IloLinearNumExpr expr = cplex.linearNumExpr();
expr.addTerm(1.0, x[0]);
expr.addTerm(2.0, x[1]);
expr.addTerm(3.0, x[2]);
定义目标函数
cplex.addMinimize(expr)
定义约束条件
cplex.addLe(cplex.sum(cplex.negative(x[0]), x[1], x[2]), 20);
取值
double[] xval = cplex.getValues(x);