Examples of Solution


Examples of com.oti.Solution

        currEvalue = currEvalue.parent;
      }
    }
    // reverse the list
    Collections.reverse(revMoves);
    Solution sol = new Solution();
    for (Move move : revMoves) {
//          Piece pieceToMove = move.getPiece();
//          Location nextLocation = move.getNextLocation();
//      System.out.println();
//            System.out.printf("\tcom.oti.Move: %s to %s\n", pieceToMove, nextLocation);
           
      sol.add( move);
    }
   
   
    return sol;
  }
View Full Code Here

Examples of de.timefinder.data.algo.Solution

    void clearInvalid() {
        getInvalidAssignments().clear();
    }

    public Solution export() {
        Solution solution = new Solution();
        solution.setHardConflicts(getHardConstraintsViolations());
        solution.setSoftConflicts(getSoftConstraintsViolations());

        for (Assignment ass : allAssignments) {
            solution.addAssignment(new Assignment(ass));
        }

        return solution;
    }
View Full Code Here

Examples of de.timefinder.data.algo.Solution

    public void testRunAlgorithm() {
        System.out.println("runAlgorithm");
        DataPool4Track2 dataPool4Track2 = createDP4Track2();
        dataPool4Track2.doWork();
        assertTrue(ncpInstance.getDataPool().getDao(Event.class).getAll().size() > 100);
        Solution sol = ncpInstance.doWork();
        ConstraintChecker.printStatistics(sol, true);
        assertTrue("Optimization is not efficient enough!", ncpInstance.getHardConflicts() < 20);
    }
View Full Code Here

Examples of de.timefinder.data.algo.Solution

        ncpInstance.setDataPool(dataPool);

        loadData(dataPool, new File(fileOrFolder), settings);

        long start = System.currentTimeMillis();
        Solution solution = ncpInstance.doWork();
//        ConstraintChecker.printStatistics(solution);

        return start;
    }
View Full Code Here

Examples of driftingdroids.model.Solution

        String maxSolution = "";
        for (int i = 1; i <= numGames; ++i) {
           
            theBoard.setRobotsRandom();
            final Solver theSolver = Solver.createInstance(theBoard);
            final Solution theSolution = theSolver.execute().get(0);
            final int moves = theSolution.size();
           
            //System.err.println(i + " usedMem=" + (getBytesUsed() >> 20) + " MiB  " + theSolver.getKnownStatesNumber());
           
            if ((0 == i % 100) || (moves > maxMoves)) {
                String msg = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
View Full Code Here

Examples of javax.constraints.Solution

//    if (solver.getMaxNumberOfSolutions() > 0)
//      constrainer.set
    boolean trace = false;
    boolean goal_saves_solution = true;
    GoalFastMinimize optimizationGoal = new GoalFastMinimize(totalGoal, cObj, trace, goal_saves_solution);
    Solution solution = null;
    try {
      if (constrainer.execute(optimizationGoal)) {
//        solution = new BasicSolution(this,1);
//        solution.setSolutionNumber(optimizationGoal.numberOfSolutions());
        solution = this.getSolution();
View Full Code Here

Examples of kodkod.engine.Solution

        if (simp!=null && formulas.size()>0 && !simp.simplify(rep, this, formulas)) addFormula(Formula.FALSE, Pos.UNKNOWN);
        rep.translate(opt.solver.id(), bitwidth, maxseq, solver.options().skolemDepth(), solver.options().symmetryBreaking());
        Formula fgoal = Formula.and(formulas);
        rep.debug("Generating the solution...\n");
        kEnumerator = null;
        Solution sol = null;
        final Reporter oldReporter = solver.options().reporter();
        final boolean solved[] = new boolean[]{true};
        solver.options().setReporter(new AbstractReporter() { // Set up a reporter to catch the type+pos of skolems
            @Override public void skolemizing(Decl decl, Relation skolem, List<Decl> predecl) {
                try {
                    Type t=kv2typepos(decl.variable()).a;
                    if (t==Type.EMPTY) return;
                    for(int i=(predecl==null ? -1 : predecl.size()-1); i>=0; i--) {
                        Type pp=kv2typepos(predecl.get(i).variable()).a;
                        if (pp==Type.EMPTY) return;
                        t=pp.product(t);
                    }
                    kr2type(skolem, t);
                } catch(Throwable ex) { } // Exception here is not fatal
            }
            @Override public void solvingCNF(int primaryVars, int vars, int clauses) {
               if (solved[0]) return; else solved[0]=true; // initially solved[0] is true, so we won't report the # of vars/clauses
               if (rep!=null) rep.solve(primaryVars, vars, clauses);
           }
        });
        if (!opt.solver.equals(SatSolver.CNF) && !opt.solver.equals(SatSolver.KK) && tryBookExamples) { // try book examples
           A4Reporter r = "yes".equals(System.getProperty("debug")) ? rep : null;
           try { sol = BookExamples.trial(r, this, fgoal, solver, cmd.check); } catch(Throwable ex) { sol = null; }
        }
        solved[0] = false; // this allows the reporter to report the # of vars/clauses
        for(Relation r: bounds.relations()) { formulas.add(r.eq(r)); } // Without this, kodkod refuses to grow unmentioned relations
        fgoal = Formula.and(formulas);
        // Now pick the solver and solve it!
        if (opt.solver.equals(SatSolver.KK)) {
            File tmpCNF = File.createTempFile("tmp", ".java", new File(opt.tempDirectory));
            String out = tmpCNF.getAbsolutePath();
            Util.writeAll(out, debugExtractKInput());
            rep.resultCNF(out);
            return null;
         }
        if (opt.solver.equals(SatSolver.CNF)) {
            File tmpCNF = File.createTempFile("tmp", ".cnf", new File(opt.tempDirectory));
            String out = tmpCNF.getAbsolutePath();
            solver.options().setSolver(WriteCNF.factory(out));
            try { sol = solver.solve(fgoal, bounds); } catch(WriteCNF.WriteCNFCompleted ex) { rep.resultCNF(out); return null; }
            // The formula is trivial (otherwise, it would have thrown an exception)
            // Since the user wants it in CNF format, we manually generate a trivially satisfiable (or unsatisfiable) CNF file.
            Util.writeAll(out, sol.instance()!=null ? "p cnf 1 1\n1 0\n" : "p cnf 1 2\n1 0\n-1 0\n");
            rep.resultCNF(out);
            return null;
         }
        if (solver.options().solver()==SATFactory.ZChaff || !solver.options().solver().incremental()) {
           rep.debug("Begin solve()\n");
           if (sol==null) sol = solver.solve(fgoal, bounds);
           rep.debug("End solve()\n");
        } else {
           rep.debug("Begin solveAll()\n");
           kEnumerator = new Peeker<Solution>(solver.solveAll(fgoal, bounds));
           if (sol==null) sol = kEnumerator.next();
           rep.debug("End solveAll()\n");
        }
        if (!solved[0]) rep.solve(0, 0, 0);
        final Instance inst = sol.instance();
        // To ensure no more output during SolutionEnumeration
        solver.options().setReporter(oldReporter);
        // If unsatisfiable, then retreive the unsat core if desired
        if (inst==null && solver.options().solver()==SATFactory.MiniSatProver) {
           try {
              lCore = new LinkedHashSet<Node>();
              Proof p = sol.proof();
              if (sol.outcome()==UNSATISFIABLE) {
                 // only perform the minimization if it was UNSATISFIABLE, rather than TRIVIALLY_UNSATISFIABLE
                 int i = p.highLevelCore().size();
                 rep.minimizing(cmd, i);
                 if (opt.coreMinimization==0) try { p.minimize(new RCEStrategy(p.log())); } catch(Throwable ex) {}
                 if (opt.coreMinimization==1) try { p.minimize(new HybridStrategy(p.log())); } catch(Throwable ex) {}
View Full Code Here

Examples of main.Solution

     * Prepara los parametros necesarios y los introduce al algoritmo para obtener una solucion.    
     */
    public boolean solveProblem(Stack<AuxiliarElement> futureObjects){
        Stack<AuxiliarElement> auxiliar;
        Algorithm alg;
        Solution sol;       
        int ret;
        auxiliar = (Stack)futureObjects.clone();
        if((x*y) < (areaOc*2)/3){           
            return false;
        }
        alg = new Algorithm();
        sol = new Solution(x, y, auxiliar);
        sol.setIdRoom(idRoom);
        int ndoors = 0;
        for(int i = 0; i < posDoor.length; i++){
            if(posDoor[i][0]==0){
                sol.placeDoor(posDoor[i][1]+20, 0, 50, 50, auxiliar.size()+(i+1));
            }else if(posDoor[i][1]==0){
                int stride = posDoor[i][0]+50;
                sol.placeDoor(stride, 3, 50, 50, auxiliar.size()+(i+1));
            }else if((posDoor[i][1]+50)==y){
                sol.placeDoor(posDoor[i][0]+20, 1, 50, 50, auxiliar.size()+(i+1));
            }else if((posDoor[i][0]+50)==x){
                int stride = posDoor[i][1]+50;
                sol.placeDoor(stride+20, 2, 50, 50, auxiliar.size()+(i+1));
            }
            ndoors = (i+1);
        }
        for(int i = 0; i < posWindow.length; i++){
            if(posWindow[i][0]==0){
                sol.placeWindow(posWindow[i][1], 0, 50, 50, auxiliar.size()+(i+ndoors+1));
            }else if(posWindow[i][1]==0){
                int stride = posWindow[i][0]+50;
                sol.placeWindow(stride, 3, 50, 50, auxiliar.size()+(i+ndoors+1));
            }else if((posWindow[i][1]+50)==y){
                sol.placeWindow(posWindow[i][0], 1, 50, 50, auxiliar.size()+(i+ndoors+1));
            }else if((posWindow[i][0]+50)==x){
                int stride = posWindow[i][1]+50;
                sol.placeWindow(stride, 2, 50, 50, auxiliar.size()+(i+ndoors+1));
            }
        }
        ret = alg.forwardCheck(futureObjects, sol,this.configurationController.getCjtRestrictionsController());
        futureObjects = (Stack)auxiliar.clone();       
        if (ret == 0){           
            alg.backtracking(futureObjects, sol, this.configurationController.getCjtRestrictionsController());
        }       
        actualElements = (Stack)auxiliar.clone();        
       
        return !sol.isFail();
    }
View Full Code Here

Examples of net.sf.cpsolver.ifs.solution.Solution

        if (solver.lastSolution().getBestInfo() == null)
            logger.severe("No solution found :-(");

        logger.info("Last solution:" + solver.lastSolution().getInfo());
        logger.info("Best solution:" + solver.lastSolution().getBestInfo());
        Solution best = solver.lastSolution();
        best.restoreBest();
        int value = 0;
        for (Enumeration iv = best.getModel().assignedVariables().elements(); iv.hasMoreElements();) {
            value += (int) ((Variable) iv.nextElement()).getAssignment().toDouble();
        }

        logger.info("Last solution:" + best.getInfo());
        logger.info(doubleFormat.format(properties.getPropertyDouble("Generator.FillFactor", 0.0)) + ";"
                + doubleFormat.format(properties.getPropertyInt("Generator.NrRooms", 0)) + ";");
        logger.info(doubleFormat.format(best.getTime()) + ";" + best.getIteration() + ";"
                + doubleFormat.format(((double) best.getIteration()) / best.getTime()) + ";");
        logger.info(best.getModel().assignedVariables().size() + ";"
                + doubleFormat.format(100.0 * best.getModel().assignedVariables().size()
                / best.getModel().variables().size()) + ";" + value);
        logger.info("    time:         " + doubleFormat.format(best.getTime()) + " s");
        logger.info("    iteration:    " + best.getIteration());
        logger.info("    speed:        " + doubleFormat.format(((double) best.getIteration())
                / best.getTime()) + " it/s");
        logger.info("    assigned:     " + best.getModel().assignedVariables().size()
                + " (" + doubleFormat.format(100.0 * best.getModel().assignedVariables().size()
                / best.getModel().variables().size()) + "%)");
        logger.info("    value:        " + value);

        // remove previous assignments
        for (Location loc : locToRoom.keySet()) {
            for (Event ev : loc.getEvents()) {
View Full Code Here

Examples of org.drools.planner.core.solution.Solution

    public void solvingStarted(AbstractSolverScope abstractSolverScope) {
        Score initialScore = abstractSolverScope.calculateScoreFromWorkingMemory();
        abstractSolverScope.setStartingScore(initialScore);
        abstractSolverScope.setBestSolutionStepIndex(-1);
        Solution newBestSolution = abstractSolverScope.getWorkingSolution().cloneSolution();
        abstractSolverScope.setBestSolution(newBestSolution);
        abstractSolverScope.setBestScore(initialScore);
        solverEventSupport.fireBestSolutionChanged(newBestSolution); // TODO if solution is initialized it should not fire an event
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.