Package solver.search.strategy.strategy

Examples of solver.search.strategy.strategy.AbstractStrategy


      public void onSolution() {
        prettyOut();
      }
    });
    /* Heuristic choices */
    AbstractStrategy strat = IntStrategyFactory.minDom_LB(next);
    solver.set(IntStrategyFactory.lastConflict(solver,strat));
//    solver.set(strat);
  }
View Full Code Here


        solver.post(IntConstraintFactory.knapsack(objects, scalar, power, volumes, energies));
    }

    @Override
    public void configureSearch() {
        AbstractStrategy strat = IntStrategyFactory.lexico_LB(objects);
        // trick : top-down maximization
        solver.set(new ObjectiveStrategy(power, OptimizationPolicy.TOP_DOWN), strat);
    }
View Full Code Here

        IntVar[] variables = new IntVar[n];
        for (int i = 0; i < n; i++) {
            variables[i] = VariableFactory.enumerated("V" + i, i, n + i, s);
        }
        AbstractStrategy asg = IntStrategyFactory.lexico_LB(variables);

        s.set(asg);

        env.worldPush();
        Decision decision = asg.getDecision();
        for (int i = 0; i < n; i++) {
            decision.buildNext();
            try {
                decision.apply();
            } catch (ContradictionException e) {
                e.printStackTrace();
            }
            Assert.assertTrue(variables[i].isInstantiated());
            Assert.assertEquals(variables[i].getValue(), i);
            Decision tmp = decision;
            decision = asg.getDecision();
            if (decision != null) {
                decision.setPrevious(tmp);
            } else {
                decision = tmp;
            }
View Full Code Here

        for (int i = 0; i < n; i++) {
            variables[i] = VariableFactory.enumerated("V" + i, i, n + i, s);
            asgs[i] = IntStrategyFactory.lexico_LB(variables[i]);
        }

        AbstractStrategy sts = ISF.sequencer(asgs);

        s.set(sts);

        env.worldPush();
        Decision decision = sts.getDecision();
        for (int i = 0; i < n; i++) {
            decision.buildNext();
            try {
                decision.apply();
            } catch (ContradictionException e) {
                e.printStackTrace();
            }
            Assert.assertTrue(variables[i].isInstantiated());
            Assert.assertEquals(variables[i].getValue(), i);
            Decision tmp = decision;
            decision = sts.getDecision();
            if (decision != null) {
                decision.setPrevious(tmp);
            } else {
                decision = tmp;
            }
View Full Code Here

        IntVar[] x = VariableFactory.enumeratedArray("x", 5, 1, 6, solver);
        SetVar y = VariableFactory.set("y", 1, 10, solver);
        solver.post(ICF.alldifferent(x));
        solver.post(SetConstraintsFactory.member(x[0], y));
        solver.findSolution();
        AbstractStrategy strat = solver.getStrategy();
        Assert.assertTrue(strat instanceof StrategiesSequencer);
    }
View Full Code Here

        Constraint[] lcstrs = new Constraint[3];
        lcstrs[0] = IntConstraintFactory.arithm(vars[0], "<", vars[1]);
        lcstrs[1] = IntConstraintFactory.arithm(vars[1], "<", vars[2]);
        lcstrs[2] = IntConstraintFactory.arithm(vars[0], "!=", vars[1]);
        // configure Solver
        AbstractStrategy strategy = IntStrategyFactory.lexico_LB(vars);
        s.post(lcstrs);
        s.set(strategy);
        // solve
        s.findSolution();
        long sol = s.getMeasures().getSolutionCount();
View Full Code Here

                s.post(IntConstraintFactory.arithm(diag2[i], "=", vars[i], "+", i));
            }
            s.post(IntConstraintFactory.alldifferent(diag1, "BC"));
            s.post(IntConstraintFactory.alldifferent(diag2, "BC"));
        }
        AbstractStrategy strategy = IntStrategyFactory.lexico_LB(vars);
        s.set(strategy);
        s.findAllSolutions();
        long sol = s.getMeasures().getSolutionCount();
        Assert.assertEquals(sol, nbSol, "nb sol incorrect");
    }
View Full Code Here

        Constraint[] cstrs = {
                IntConstraintFactory.arithm(Y, "!=", 4)
        };

        AbstractStrategy strategy = IntStrategyFactory.lexico_LB(vars);

        s.post(cstrs);
        s.set(strategy);
        s.findAllSolutions();
        Assert.assertEquals(s.getMeasures().getSolutionCount(), 2);
View Full Code Here

        Constraint[] cstrs = {
                IntConstraintFactory.arithm(Y, "!=", -2)
        };

        AbstractStrategy strategy = IntStrategyFactory.lexico_LB(vars);

        s.post(cstrs);
        s.set(strategy);
        s.findAllSolutions();
        Assert.assertEquals(s.getMeasures().getSolutionCount(), 4);
View Full Code Here

        Constraint[] cstrs = {
                IntConstraintFactory.arithm(Y, ">=", low + coeff - 1),
                IntConstraintFactory.arithm(Y, "<=", upp - coeff - 1)
        };

        AbstractStrategy strategy = IntStrategyFactory.lexico_LB(vars);

        s.post(cstrs);
        s.set(strategy);
        return s;
    }
View Full Code Here

TOP

Related Classes of solver.search.strategy.strategy.AbstractStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.