Revision 187:5e99ab6182d8

View differences:

src/main/java/cz/agents/dimaptools/heuristic/relaxed/RecursiveDistributedRelaxationRequestHeuristic.java
47 47
//	private int heuristicCounter = 0;
48 48

  
49 49
    protected final int maxRecursionDepth;
50
    
51
    private final boolean localRequestsLIFO;
50 52

  
51 53
    /**
52 54
     * Remember actions already requested
......
59 61
    public RecursiveDistributedRelaxationRequestHeuristic(DIMAPWorldInterface world,EvaluatorInterface evaluator) {
60 62
        this(world,evaluator,Integer.MAX_VALUE);
61 63
    }
64
    
65
    public RecursiveDistributedRelaxationRequestHeuristic(DIMAPWorldInterface world,EvaluatorInterface evaluator,int maxRecursionDepth){
66
    	this(world,evaluator,maxRecursionDepth,true);
67
    }
62 68

  
63
    public RecursiveDistributedRelaxationRequestHeuristic(DIMAPWorldInterface world,EvaluatorInterface evaluator,int maxRecursionDepth) {
69
    public RecursiveDistributedRelaxationRequestHeuristic(DIMAPWorldInterface world,EvaluatorInterface evaluator,int maxRecursionDepth,boolean localRequestsLIFO) {
64 70
        super(world.getProblem(),evaluator,true);
65 71

  
66 72
        comm = world.getCommunicator();
......
68 74
        agentID = world.getAgentID();
69 75

  
70 76
        this.maxRecursionDepth = maxRecursionDepth > -1 ? maxRecursionDepth : Integer.MAX_VALUE;
77
        this.localRequestsLIFO = localRequestsLIFO;
71 78

  
72 79
        requestProtocol = new DistributedHeuristicRequestProtocol(
73 80
                world.getCommunicator(),
......
244 251
    public void processMessages() {
245 252

  
246 253
        while(requests.size() == 0 && localRequests.size() > 0){
247
            LocalHeuristicRequest lr = localRequests.pollLast();
254
            LocalHeuristicRequest lr;
255
            
256
            if(localRequestsLIFO){
257
            	lr = localRequests.pollLast();	//LIFO
258
            }else{
259
            	lr = localRequests.pollFirst();	//FIFO
260
            }
248 261

  
249 262
            getHeuristic(lr.state, lr.callback);
250 263
        }

Also available in: Unified diff