Example #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);
  }
  @Override
  public void setup(Topology topology, TaskDistribution td, Agent agent) {
    this.topology = topology;
    this.td = td;
    this.agent = agent;

    // initialize the planner
    int capacity = agent.vehicles().get(0).capacity();
    String algorithmName = agent.readProperty("algorithm", String.class, "ASTAR");

    // Throws IllegalArgumentException if algorithm is unknown
    algorithm = Algorithm.valueOf(algorithmName.toUpperCase());
  }
Example #3
0
  @Override
  public void setup(Topology topology, TaskDistribution distribution, Agent agent) {

    this.topology = topology;
    this.distribution = distribution;
    this.agent = agent;
    this.vehicles = agent.vehicles();
    this.currentTasks = new ArrayList<Task>();

    this.currentSolution = new Solution(this.vehicles.size());

    this.timeout_bid = LogistPlatform.getSettings().get(LogistSettings.TimeoutKey.BID);
    this.timeout_plan = LogistPlatform.getSettings().get(LogistSettings.TimeoutKey.PLAN);
  }