示例#1
0
  @Override
  public Long askPrice(Task task) {

    System.out.println("Ask price");

    long startTime = System.currentTimeMillis();
    long endTime = startTime + timeout_bid;

    Vehicle[] vArray = new Vehicle[agent.vehicles().size()];
    vArray = agent.vehicles().toArray(vArray);

    List<Task> futureTasks = new ArrayList<Task>(currentTasks);
    futureTasks.add(task);

    this.futureSolution =
        CentralizedPlanner.centralizedSolution(vehicles, futureTasks, endTime - 1000);
    double cost = this.futureSolution.computeCost(vArray);

    double marginalCost = Math.abs(cost - currentSolution.computeCost(vArray));

    // ----- STRATEGY --------------

    Random r = new Random();

    double randomRatio = 1 + r.nextDouble();

    if (marginalCost > 1000 && r.nextDouble() > 0.9) marginalCost = 7000;
    if (marginalCost == 0) marginalCost = 50;

    double futureScore = getOpportunityExpected(task.pickupCity, task.deliveryCity);

    return (long) Math.ceil((randomRatio - futureScore) * marginalCost);
  }
示例#2
0
 @Override
 protected Solution clone() {
   Solution s = new Solution(nbVehicles);
   s.setSolution(new HashMap<Integer, List<ExtendedTask>>(this.solution));
   return s;
 }