Revision 181:772fad8abfcd

View differences:

src/main/java/cz/agents/dimaptools/search/DistributedBestFirstSearch.java
47 47
    protected HeuristicInterface requestHeuristic;
48 48
    protected SearchCallback planCallback;
49 49

  
50
    protected boolean recomputeHeuristicOnReceive = false;
50 51

  
51 52
    protected final Communicator comm;
52 53
    protected final CommunicationPerformer commPerformer;
......
122 123

  
123 124

  
124 125
    protected void addReceivedState(StateMessage sm, String sender){
125
        open.add(new SearchState(problem.initState.getDomain(),sm,sender));
126
    	if(recomputeHeuristicOnReceive){ //should be probably done for projected heuristics
127
    		final SearchState newState = new SearchState(problem.initState.getDomain(),sm,sender);
128
    		
129
    		heuristic.getHeuristic(newState, new HeuristicComputedCallback() {
130
				
131
				@Override
132
				public void heuristicComputed(HeuristicResult result) {
133
					open.add(newState);
134
				}
135
			});
136
    		
137
    	}else{
138
    		
139
    		open.add(new SearchState(problem.initState.getDomain(),sm,sender));
140
    		
141
    	}
126 142
    }
127 143

  
128

  
129

  
130
    @Override
131
    public void plan(ConfigurationInterface config, SearchCallback planCallback) {
132

  
133
        if(config.containsKey("heuristic")){
144
    
145
    protected void readConfiguration(ConfigurationInterface config){
146
    	if(config.containsKey("heuristic")){
134 147
            heuristic = (HeuristicInterface) config.getObject("heuristic");
135 148
        }
136 149

  
......
139 152
        }else{
140 153
            requestHeuristic = heuristic;
141 154
        }
155
        
156
        recomputeHeuristicOnReceive = config.getBoolean("recomputeHeuristicOnReceive", false);
157
    }
142 158

  
143 159

  
160
    @Override
161
    public void plan(ConfigurationInterface config, SearchCallback planCallback) {
162

  
163
    	readConfiguration(config);
164

  
144 165
        this.planCallback = planCallback;
145 166

  
146 167
        open.add(new SearchState(problem.initState));
src/main/java/cz/agents/dimaptools/search/MultiheuristicDistributedBestFirstSearch.java
64 64
        return true;
65 65
    }
66 66

  
67
    private void readConfiguration(ConfigurationInterface config){
67
    @Override
68
    protected void readConfiguration(ConfigurationInterface config){
68 69

  
69 70
        if(config.containsKey("heuristic") && !config.containsKey("requestHeuristic")){
70 71
            boolean usePreferred = config.containsKey("preferred") ? (Boolean)config.getObject("preferred") : false;
......
86 87
        
87 88
        strategy = OpenSelectionStrategy.valueOf(config.getString("openSelectionStrategy", OpenSelectionStrategy.ALTERNATE.name()));
88 89
        
90
        recomputeHeuristicOnReceive = config.getBoolean("recomputeHeuristicOnReceive", false);
89 91

  
90 92
    }
91 93

  
......
93 95
    public void plan(ConfigurationInterface config, SearchCallback planCallback) {
94 96

  
95 97
        readConfiguration(config);
98
        
99
        
96 100

  
97 101
        this.planCallback = planCallback;
98 102

  
src/main/java/cz/agents/dimaptools/search/SyncDistributedBestFirstSearch.java
39 39
    }
40 40

  
41 41

  
42
    protected void addReceivedState(StateMessage sm, String sender){
43
        open.add(new SearchState(problem.initState.getDomain(),sm,sender));
44
    }
45

  
46 42

  
47 43

  
48 44
    @Override
49 45
    public void plan(ConfigurationInterface config, SearchCallback planCallback) {
50 46

  
51
        if(config.containsKey("heuristic")){
52
            heuristic = (HeuristicInterface) config.getObject("heuristic");
53
        }
54

  
55
        if(config.containsKey("requestHeuristic")){
56
            requestHeuristic = (HeuristicInterface) config.getObject("requestHeuristic");
57
        }else{
58
            requestHeuristic = heuristic;
59
        }
47
    	readConfiguration(config);
60 48

  
61 49

  
62 50
        this.planCallback = planCallback;

Also available in: Unified diff