 
              
 
              Illustration courtesy Stuart Russell and Peter Norvig, Artificial Intelligence - a Modern Approach, Pearson.
 
           
           
           
           
           
           
           
           
              Illustration courtesy Stuart Russell and Peter Norvig, Artificial Intelligence - a Modern Approach, Pearson.
 
              Illustration courtesy Stuart Russell and Peter Norvig, Artificial Intelligence - a Modern Approach, Pearson.
 
               
               
              
 
              This Java code is provided by Shunki Takami et al.
 
              Illustration courtesy Stuart Russell and Peter Norvig, Artificial Intelligence - a Modern Approach, Pearson.
 
              Illustration courtesy Mircea Traichioiu, Hierarchical Decision Theoretic Planning for RoboCup Rescue Agent Simulation, Master thesis, University of Amsterdam, 2014.
            
          
                
                For (Entity next: this.worldInfo.getEntities() ) {
                 	 loc = this.worldInfo.getLocation(next.getID()); 
                 	
                matlab.eval("G=addnode(G,table(next.getID(),loc.first(),loc.second());");
                }
 For (Entity next: this.worldInfo.getEntities() )
                 	 Collection areaNeighbours = next.getNeighbours();
                
  	 for(entityID neighbour : areaNeigbours) {
                 	 	
                matlab.eval("G=addedge(G,find(next.getID()),find(neighbour.getID());");
                 	 }
 }
                matlab.eval("save('graph.mat',G);");
              
            
          
 
              
| no batch | 15,7999 s | 
| batch of 25 | 1,6564 s | 
| batch of 250 | 0,6677 s | 
| batch of 2500 | 0,42233 s | 
            
          
                cd ~ 
 mkdir git
 cd git
 git clone
                https://github.com/roborescue/rcrs-server.git
 cd
                rcrs-server
 ant clean-all
 ant complete-build
                
 cd boot
 ./start-precompute.sh -m
                ../maps/gml/kobe/map/ -c ../maps/gml/kobe/config/
              
            
          
            
          
                cd ~ 
 mkdir git
 cd git
 git clone
                https://github.com/IntelligentRoboticsLab/Joint-Rescue-Forces.git
                cd Joint-Rescue-Forces
 ./precompute-matlab.sh 1 0 1 0 1 0
                localhost
              
          
            
          
                load ../data/graph.mat
                plot(G,'NodeLabel',cellstr(G.Nodes.ID));
              
            
          
            
          
                figure(2)
                plot(G,'xdata',G.Nodes.X,'ydata',G.Nodes.Y,'NodeLabel',cellstr(G.Nodes.ID));
              
            
          
 
  
              
                from = find(G.Nodes.ID=="36373");
 target =
                [find(G.Nodes.ID=="33976") find(G.Nodes.ID=="35378")
                find(G.Nodes.ID=="34146")];
 [TR,D] =
                shortestpathtree(G,from,target,'OutputForm','cell');
              
          
 
              
                D = 
  	 252553 68434 397069
 TR =
                 	 {1×37 double}
  	 {1×9 double}
                 	 {1×66 double}
              
            
          Highlight_path is a function of Peter Corke's Robotics toolbox
 
              
                PG.shortestpath(M(char("36373")),M(char("33976")),'algorithm',
                'depth-first', 'timer') 
 costs=256829, time=0.087983
                PG.shortestpath(M(char("36373")),M(char("33976")),'algorithm',
                'Astar', 'timer') 
 costs=252553, time=0.095392
                PG.shortestpath(M(char("36373")),M(char("33976")),'algorithm',
                'Dijkstra', 'timer') 
 costs=252553, time=0.202984
              
            
          shortestpath is modification of Peter Corke's open source Astar implementation.
 
              
                neighbours = PG.neighbours(909);
 edges = PG.edges(909);
                new_cost = 4 .* PG.cost(edges);
 [path_index,C] =
                PG.shortestpath(M(char("36373")),M(char("33976")),'algorithm',
                'Astar');
              
          Blockade illustration is courtesy Ali Modaresi.
 
              How is clustering useful to Rescue Agent Simulation?
 
          Commonly, Partition Clustering Methods are used, such as K-Means++ or K-Medoid
floorstotalAreafierynesstemperature 
          buildingID;x;y;totalArea;floors
                40964;1811658;238270;129;1 49162;1148956;194238;876;1
                57356;683596;1257545;500;1 57358;657794;1270839;801;1
                24591;1828352;222217;163;1
          
                cd rcrs-server/boot
 ./start.sh -m
                $JOINT_RESCUE_FORCES/tutorial/paris/map/ -c
                $JOINT_RESCUE_FORCES/tutorial/paris/config/
              
            
          
            
          
                cd Joint-Rescue-Forces
 ./data-generation.sh
              
           
          
                %% Perform k-Medoids clustering and plot the results
                numMedoids = 5;
 [indices,centroids] = kmeans([buildings.x
                buildings.y],numMeans);
 
 figure
 hold on
                gscatter(buildings.x,buildings.y,indices)
                plot(centroids(:,1),centroids(:,2),'kx','MarkerSize',10,'LineWidth',2)
                hLegend = legend;
 hLegend.String{end} = 'centroids';
                title('k-Medoids Clustered Map'); xlabel('X position');
                ylabel('Y position');
               
          Hands-on
                addpath('tutorial/scripts/clustering')
                addpath('tutorial/data/unsupervised') 
building_cluster
              
           
          ml =
                        MatlabEngine.startMatlab();double[][] mlInputk-means function
                Object[] mlOutput =
                        ml.feval( 2, "kmeans", (Object) mlInput,
                        this.clusterSize, DISTANCE, this.distanceMetric,
                        MAX_ITER, this.maxIter );double[] mlIndex =
                        (double[]) mlOutput[0];double[][] mlCenter =
                        (double[][]) mlOutput[1];MatlabEngine
                  ml = MatlabEngine.startMatlab();
            
                  if ( MatlabEngine.findMatlab().length > 0 ) {
                     MatlabEngine ml =
                  MatlabEngine.connectMatlab();
 }
                matlab.engine.shareEngine
                [output1,...,outputN]
                  = eval(expression)ml.eval('cd
                  tutorial;')[y1,...,yN]
                  = feval(fun,x1,...,xM) Object[] mlOutput = ml.feval( 2,
                  "kmeans", (Object) mlInput, 10, DISTANCE, 'cityblock',
                  MAX_ITER, 100 );
             
        
                  id;sTime;sDist;sHP;sDamage;eTime;eDist;eHP;eDamage
                  2146824103;12;934003;10000;0;56;0;8500;0
                  1285094217;12;1014231;10000;0;98;0;7000;80
                  1329519353;16;74983;10000;0;62;0;8500;0
                  2029710813;48;245461;8500;0;122;0;4500;80
                  802454469;33;1254470;9500;0;109;0;6500;80
                  1684298116;43;664753;9500;0;96;0;8500;0
                
            
                cd rcrs-server/boot
 ./start.sh -m
                $JOINT_RESCUE_FORCES/tutorial/paris/map/ -c
                $JOINT_RESCUE_FORCES/tutorial/paris/config/
              
            
          
            
          
                cd Joint-Rescue-Forces
 ./data-generation.sh
              
          
                addpath('tutorial/scripts/clustering')
                addpath('tutorial/data/unsupervised')
 trainingData =
                importRescueData('training.csv');
 validationData =
                importRescueData('validation.csv');
 
 TData =
                trainingData(:, 2:end);
 VData = validationData(:, 2:end);
               
          
                hp_bins = [0 1 3000 7000 10000];
 bin_names = {'Dead',
                'Critical', 'Injured', 'Stable'};
 TData.hp_class =
                discretize(TData.eHP, hp_bins, 'categorical', bin_names);
               
           
        
                // VData is the validation data
 predictions =
                targetSelectorModel.predictFcn(VData);
 
 numCorrect
                = nnz(predictions == VData.hp_class);
 validationAccuracy
                = numCorrect/size(VData,1);
 fprintf('Validation accuracy:
                %.2f%%\n', validationAccuracy * 100);
              
          
                function predictions = selectTargets(time,dist,hp,damage)
                   persistent targetSelectorModel
                   if isempty(targetSelectorModel)
                      load targetSelectorModel
                targetSelectorModel
    end
                   predictors = table(time,dist,hp,damage, ...
                      'VariableNames',{'sTime','sDist','sHP','sDamage'});
                
    predictions =
                int32(targetSelectorModel.predictFcn(predictors));
 end
              
          calc
              method of the HumanDetector class for the ambulance
              team agents
            
                if ( MatlabEngine.findMatlab().length > 0 ) {
                   MatlabEngine ml =
                MatlabEngine.connectMatlab();
    int sTime
                = rescueTarget.sTime;
    int sDist =
                rescueTarget.sDist;
    int sHP =
                rescueTarget.sHP;
    int sDamage =
                rescueTarget.sDamage;
 
    int value
                = ml.feval( "selectTargets", sTime, sDist, sHP, sDamage );
                
    ml.close();
 }
               
          Important
MatlabEngine.findMatlab() and MatlabEngine.connectMatlab()matlab.engine.shareEngine)
              Critical 
          