1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| ExpressionsBasedModel model = new ExpressionsBasedModel(); model.addVariable(Variable.makeInteger("c"+1).lower(0).upper(3000).weight(5)); model.addVariable(Variable.makeInteger("c"+2).lower(0).upper(3000).weight(6)); model.addVariable(Variable.makeInteger("c"+3).lower(0).upper(3000).weight(23));
model.addVariable(Variable.makeBinary("ca1").lower(0).upper(1).weight(0)); model.addVariable(Variable.makeBinary("ca2").lower(0).upper(1).weight(0)); model.addVariable(Variable.makeBinary("ca3").lower(0).upper(1).weight(0));
Expression expression = model.addExpression("e" + 1); expression.set(0,1); expression.set(1,1); expression.set(2,1); expression.lower(3000); System.out.println(expression);
Expression expression2 = model.addExpression("e" + 2); expression2.set(3,1); expression2.set(4,1); expression2.set(5,1); expression2.upper(1); System.out.println(expression2);
Expression expression3 = model.addExpression("e" + 3); expression3.set(3,5000); expression3.set(0,1); expression3.upper(5000); System.out.println(expression3);
Expression expression4 = model.addExpression("e" + 4); expression4.set(3,5000); expression4.set(0,1); expression4.lower(100); System.out.println(expression4);
Expression expression5 = model.addExpression("e" + 5); expression5.set(4,5000); expression5.set(1,1); expression5.upper(5000); System.out.println(expression5);
Expression expression6 = model.addExpression("e" + 6); expression6.set(4,5000); expression6.set(1,1); expression6.lower(100); System.out.println(expression6);
Expression expression7 = model.addExpression("e" + 7); expression7.set(5,5000); expression7.set(2,1); expression7.upper(5000); System.out.println(expression7);
Expression expression8 = model.addExpression("e" + 8); expression8.set(5,5000); expression8.set(2,1); expression8.lower(100); System.out.println(expression8);
model.setOptimisationSense(Optimisation.Sense.MIN); model.options.debug(SolverORTools.class); model.options.progress(SolverORTools.class);
SolverORTools tools = SolverORTools.INTEGRATION.build(model); Optimisation.Result result = tools.solve(null); System.out.println(result);
|