Examples of Solver


Examples of choco.kernel.solver.Solver

   
    // cours le plus tot possible dans le semestre
    // TODO
   
    // solver
    Solver s = new CPSolver();
   
    // read the model
    s.read(m);
   
    // solve the problem
    s.solve();
   
    // print the value
   
  }
View Full Code Here

Examples of com.cloudera.oryx.common.math.Solver

      aggregated = tuples.foldByKey(Double.NaN, Functions.<Double>last());
    }

    Collection<UserItemStrength> input = aggregated.map(new TupleToUserItemStrength()).collect();

    Solver XTXsolver;
    Solver YTYsolver;
    try {
      XTXsolver = model.getXTXSolver();
      YTYsolver = model.getYTYSolver();
    } catch (SingularMatrixSolverException smse) {
      return Collections.emptyList();
    }

    Collection<String> result = new ArrayList<>();
    for (UserItemStrength uis : input) {
      String user = uis.getUser();
      String item = uis.getItem();
      double value = uis.getStrength();

      // Xu is the current row u in the X user-feature matrix
      float[] Xu = model.getUserVector(user);
      // Yi is the current row i in the Y item-feature matrix
      float[] Yi = model.getItemVector(item);

      double[] newXu = null;
      if (Yi != null) {
        // Let Qui = Xu * (Yi)^t -- it's the current estimate of user-item interaction
        // in Q = X * Y^t
        // 0.5 reflects a "don't know" state
        double currentValue = Xu == null ? 0.5 : VectorMath.dot(Xu, Yi);
        double targetQui = computeTargetQui(value, currentValue);
        // The entire vector Qu' is just 0, with Qui' in position i
        // More generally we are looking for Qu' = Xu' * Y^t
        if (!Double.isNaN(targetQui)) {
          // Solving Qu' = Xu' * Y^t for Xu', now that we have Qui', as:
          // Qu' * Y * (Y^t * Yi)^-1 = Xu'
          // Qu' is 0 except for one value at position i, so it's really (Qui')*Yi
          float[] QuiYi = Yi.clone();
          for (int i = 0; i < QuiYi.length; i++) {
            QuiYi[i] *= targetQui;
          }
          newXu = YTYsolver.solveFToD(QuiYi);
        }
      }

      // Similarly for Y vs X
      double[] newYi = null;
View Full Code Here

Examples of com.hpctoday.fada.integersolver.Solver

        for (Inequation ita : added_constraints)
          system.add(ita);

        log.trace("Solver 01");
        Solver solver = SolverFactory.createSolver();
        solver.set(GetStmt2(),GetDeep(),__new_variables,__local_parameters,system);
        /*
         * cout<<"\n Solver = \n"; solver.Print();
         */
        Quast local__result = solver.Max();
        /*
         * cout<<"\n local = \n"; local__result.Print();
         */
        local__result.SubstituteByString(__mapping_counters_alphas);
        result = result.Max(local__result);
        // cout<<"\n final = \n";
        // result.Print();
        // getchar();
      }
      parameter_of_maximum.add(_alpha.toString());
      result.SubstituteByString(__mapping_counters_alphas);
      result = result.EliminateRedondantLeaves(false);
      result = result.Simplify(affine_environment, GetParameters());
      // result=result.Compress();
      SetQuast(result);
    } else {
      log.trace("Not IsThereNonAffineConstraints");
     
      // all constraints are affine ==> compute the exact definition
      List<String> __local_parameters = GetParameters();
      Quast result = new Quast(); // _|_
      // build affine systems
      //int i = 0;
     
      log.trace("AffineValidStmt2: " + affine_valid_stmt2.size());
     
      for (List<Inequation> itw : affine_valid_stmt2) {

        // valid read
        List<Inequation> system = new ArrayList<Inequation>();// =*itr;
        // if(affine_environment.size()>0);
        // system=*affine_environment.begin();

        // valid write
        for (Inequation iti : itw)
          system.add(iti);

        // lexicographic precedence
        for (Inequation itp : precedence)
          system.add(itp);

        // same variable
        for (Inequation itsc : affine_index_equality)
          system.add(itsc);

        log.trace("Solver 02");
        Solver solver = SolverFactory.createSolver();
        solver.set(GetStmt2(),GetDeep(),stmt2_iteration,__local_parameters,system);
        Quast local_result = solver.Max();
        log.trace("Local Result: " + local_result);
        result = result.Max(local_result);
      }

     
View Full Code Here

Examples of driftingdroids.model.Solver

        int maxMoves = -1;
        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());
                msg += "  gamesSolved=" + i + "/" + numGames + "  maxMoves=" + (moves > maxMoves ? moves : maxMoves);
                System.out.println(msg);
            }
            if (moves > maxMoves) {
                maxMoves = moves;
                maxSolution = theBoard.toString() + "\n" + theSolver.toString() + '\n';
                System.out.println(maxSolution);
            } else {
                System.out.println("\n***** run #" + i + "  -  current maxMoves still is " + maxMoves + " *****\n");
            }
        }
View Full Code Here

Examples of hu.u_szeged.nbo.res_alloc.main.Solver

 
  public void run() {
    NBOServer.log("ResourceAllocationSolver STARTED for " +
        user.getUserName() + "'s task: " + task + ".", 1);
   
    Solver solver = new Solver();
    solver.solve(this.task);
   
    Result result = new Result(this.uniqueHash, this.problemName);
    result.add(this.problemName, solver.getOutput());
   
    try {
      for (String filename: new String[] { "eredmeny.txt", "ertekeles.txt", "kimaradt_munkak.txt" }) {
        String fileData;
        //System.out.println(System.getProperty("user.dir") + this.pathOfTask + "/" + filename);
        File file = new File(this.pathOfTask + "/" + filename);
        char buffer[] = new char[(int)file.length()];
        FileReader fileReader = new FileReader(file);
        fileReader.read(buffer);
        fileData = new String(buffer);
        result.add(filename, fileData);
     

      user.getLogs().put(this.uniqueHash, solver.getLog());

      NBOServer.log("ResourceAllocationSolver FINISHED " +
              user.getUserName()+"'s task: " + task + ".", 1)
   
    }
View Full Code Here

Examples of jinngine.physics.solver.Solver

   */
  public void testConjugateGradients1() {
   
    double epsilon = 1e-7;
   
    Solver s = new ConjugateGradients();
   
    Body b1 = new Body("default");
    Body b2 = new Body("default");
   
    Solver.NCPConstraint c1 = new NCPConstraint();
    Vector3 va =new Vector3(1,0,0);
    Vector3 vb =new Vector3(-1,0,0);
    Vector3 z = new Vector3(0,0,0);
    c1.assign(b1,b2,
        va,z,vb,z,
        va,z,vb,z,
        -Double.POSITIVE_INFINITY,Double.POSITIVE_INFINITY,null,1, 0);
   
    //This is the system
    //
    // [ 1 0 0  0 0 0  -1 0 0  0 0 0] [1 0 0  0 0 0  -1 0 0  0 0 0 ]^T x + 1= 0  =>
    // 2 x + 1 = 0 
    //
    // with the solution x = -1/2
   
    //list of bodies and constraints
    List<Body> bodies = new ArrayList<Body>();
    List<NCPConstraint> constraints = new ArrayList<NCPConstraint>();
    bodies.add(b1); bodies.add(b2); constraints.add(c1);

    //run the solver
    s.solve(constraints, bodies, 0.0);
   
    System.out.println("cg test="+c1.lambda);
   
    //expect solution 1/2
    assertTrue( Math.abs(-0.5 - c1.lambda) < epsilon )
View Full Code Here

Examples of kodkod.engine.Solver

        }
        this.s2k = ConstMap.make(s2k);
        this.stringBounds = stringBounds.unmodifiableView();
        bounds.boundExactly(KK_STRING, this.stringBounds);
        int sym = (expected==1 ? 0 : opt.symmetry);
        solver = new Solver();
        solver.options().setFlatten(false); // added for now, since multiplication and division circuit takes forever to flatten
        if (opt.solver.external()!=null) {
            String ext = opt.solver.external();
            if (opt.solverDirectory.length()>0 && ext.indexOf(File.separatorChar)<0) ext=opt.solverDirectory+File.separatorChar+ext;
            try {
View Full Code Here

Examples of net.myrrix.common.math.Solver

                                "Number of values doesn't match number of items");
   
    Generation generation = getCurrentGeneration();

    FastByIDMap<float[]> Y = generation.getY();
    Solver ytySolver = generation.getYTYSolver();
    if (ytySolver == null) {
      throw new NotReadyException();
    }

    float[] anonymousUserFeatures = null;
    Lock yLock = generation.getYLock().readLock();

    boolean anyItemIDFound = false;
    for (int j = 0; j < itemIDs.length; j++) {
      long itemID = itemIDs[j];
      float[] itemFeatures;
      yLock.lock();
      try {
        itemFeatures = Y.get(itemID);
      } finally {
        yLock.unlock();
      }
      if (itemFeatures == null) {
        continue;
      }
      anyItemIDFound = true;
      double[] userFoldIn = ytySolver.solveFToD(itemFeatures);
      if (anonymousUserFeatures == null) {
        anonymousUserFeatures = new float[userFoldIn.length];
      }
      double signedFoldInWeight = foldInWeight(0.0, values == null ? 1.0f : values[j]);
      if (signedFoldInWeight != 0.0) {
View Full Code Here

Examples of net.sf.cpsolver.ifs.solver.Solver

    public void start() throws InterruptedException {
        DataProperties properties = new DataProperties();
        properties.setProperty("General.Seed", "123321");
        UniTimeSimpleModel model = createModel();
        Solver solver = new Solver(properties);
        condition.init();
        solver.setTerminalCondition(new TerminationCondition() {

            @Override
            public boolean canContinue(Solution sltn) {
                return condition.canContinue() && !statusBar.getMyProgressMonitor().isCanceled();
            }
        });
        Progress p = new Progress();
        p.addProgressListener(new ProgressListener() {

            private String status;

            @Override
            public void statusChanged(String status) {
                this.status = status;
            }

            @Override
            public void phaseChanged(String phase) {
            }

            @Override
            public void progressChanged(long currentProgress, long maxProgress) {
                statusBar.setMessage(status + " " + currentProgress * 100f / maxProgress);
            }

            @Override
            public void progressSaved() {
            }

            @Override
            public void progressRestored() {
            }

            @Override
            public void progressMessagePrinted(Message message) {
                statusBar.setMessage(message.getMessage());
            }
        });
        solver.setProgress(p);
        solver.setInitalSolution(model);
        solver.start();
        solver.getSolverThread().join();

        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();
        }
View Full Code Here

Examples of net.sf.javailp.Solver

   
    problem.setObjective(constructObjective(), OptType.MIN);
   
    //TODO Relaxations relax = new Relaxations();
   
    final Solver solver = factory.get();
    final Result result = solver.solve(problem);
   
    if (result == null) {
      System.out.println("[ERROR]: cannot enforce constraints, no result for LP");
    } else {
     
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.