Examples of MutableDouble


Examples of org.apache.commons.lang.mutable.MutableDouble

    jdbcTemplate = new JdbcTemplate(dataSource);
  }

  public List<TagDTO> getTags(int tagcount) {
    String sql = "select value,counter from tags_values where counter>=10 order by counter desc limit ?";
    final MutableDouble maxc = new MutableDouble(1);
    final MutableDouble minc = new MutableDouble(-1);
    List<TagDTO> result = jdbcTemplate.query(sql, new RowMapper<TagDTO>() {
      @Override
      public TagDTO mapRow(ResultSet rs, int rowNum) throws SQLException {
        TagDTO result = new TagDTO();
        result.setValue(rs.getString("value"));
        double counter = Math.log(rs.getInt("counter"));
        result.setCounter(counter);

        if (maxc.doubleValue() < counter){
          maxc.setValue(counter);
        }

        if (minc.doubleValue() < 0 || counter < minc.doubleValue()){
          minc.setValue(counter);
        }

        return result;
      }
    }, tagcount);

    if (minc.doubleValue() < 0){
      minc.setValue(0);
    }

    CollectionUtils.forAllDo(result, new Closure() {
      @Override
      public void execute(Object o) {
        TagDTO tag = (TagDTO) o;
        tag.setWeight((int) Math.round(10*(tag.getCounter() - minc.doubleValue())
          / (maxc.doubleValue() - minc.doubleValue())));
      }
    });

    Collections.sort(result);

View Full Code Here

Examples of org.cspoker.common.util.MutableDouble

          logProb += Math.log(opponentRankProb);
        }
        double prob = Math.exp(logProb);
        int won = calcAmountWon(botState, maxOpponentWin, drawers,
            allPlayers);
        MutableDouble value = values.get(won);
        if (value == null) {
          values.put(won, new MutableDouble(prob));
        } else {
          value.add(prob);
        }
        totalProb += prob;
      }
    }
    return new RolloutResult(values, totalProb, (1-gameState.getTableConfiguration().getRake()));
View Full Code Here

Examples of org.nlogo.nvm.MutableDouble

    perform_1(context);
  }

  public void perform_1(Context context) {
    Turtle turtle = (Turtle) context.agent;
    MutableDouble countdown = (MutableDouble) context.getLet(let);
    double distance = countdown.value();
    double distanceMagnitude = StrictMath.abs(distance);
    if (distanceMagnitude <= org.nlogo.api.Constants.Infinitesimal()) {
      context.ip = next;
      return;
    }
    if (distanceMagnitude <= 1.0) {
      try {
        turtle.jump(distance);
      } catch (AgentException e) { } // NOPMD
      context.ip = next;
    } else {
      int stepDistance = (distance > 0) ? 1 : -1;
      try {
        turtle.jump(stepDistance);
        countdown.value_$eq(countdown.value() - stepDistance);
      } catch (AgentException e) {
        context.ip = next;
      }
    }
  }
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.