CloudRunner

... share your algorithms as a web service

Algorithm: MMOSPA Estimation for Two Targets in 3D

Description:
Calculates the exact MMOSPA estimate for two three-dimensional targets when a particle distribution is given
Paper: For details, see the following paper:

Marcus Baum, Peter Willett, Uwe D. Hanebeck, Calculating Some Exact MMOSPA Estimates for Particle Distributions, Proceedings of the 15th International Conference on Information Fusion (Fusion 2012), Singapore, July, 2012.
Tags: MMOSPA
Depends On: "Topological Sweep of a Line Arrangement" by marcus.baum (latest version)
Usage: Algorithm is public.
Viewed 2029 times, called 76 times
Upload:
Empty star Empty star Empty star Empty star Empty star
0 votes
Marcus Baum
11/05/2013 3:43 a.m. (version #1)

Run Algorithm

: Number of samples from the example density
: Allow cached result?
Close

Please Wait

Computation is running...

Plots

showing plot # of

Result Value(s)


		

Resource Usage

Execution of the algorithm took seconds.
Peak memory usage for running the algorithm was kilobytes (total usage: kilobytes).

Run ID / Link

ID of this run:
Link:

Result from Cache

Result has been delivered from cache and computed on (UTC).

Matlab log

(show)

		

Error

Using this algorithm in your local MATLAB environment is easy: Click here for instructions!

Usage Instructions for CloudRunner Client

  1. Download the CloudRunner Client by clicking here and place the downloaded file in your MATLAB working directory.

  2. Inside MATLAB, initialize the CloudRunner Client by calling CloudRunner:
    >> CloudRunner

    A login dialog will prompt for your CloudRunner mail address and password. For a start, you can leave the dialog empty and just click "Connect".

    Alternatively, you can provide the login credentials (or empty strings to skip login) as a parameter and hence skip the login dialog. This is useful when using CloudRunner in non-interactive scripts.
    >> CloudRunner('mail@example.com', 'password')

  3. Select this algorithm by its URL. Selecting an algorithm creates the lambda function that proxies calls to the algorithm to the server for execution:
    >> CloudRunnerSelect('http://www.cloudrunner.eu/algorithm/148/mmospa-estimation-for-two-targets-in-3d/version/1/')

    For the sake of convenience, you can also use the algorithm ID instead of its URL for public algorithms.

  4. Call functions from the algorithm like any regular local function.

Note: You can find further information on the help page.

Source Code

File:

 1 function MMOSPA_TwoTargets3D(nr_particles)
 2 %
 3 % Example for the exact algorithm for the Minimum Mean Optimal Subpattern Assignment (MMOSPA) estimate
 4 % for two 3D objects with a probability density given by particles.
 5 % For details, see the paper
 6 % 
 7 % Marcus Baum, Peter Willett, Uwe D. Hanebeck, Calculating Some Exact MMOSPA Estimates for Particle Distributions,
 8 % Proceedings of the 15th International Conference on Information Fusion (Fusion 2012), Singapore, July, 2012.
 9 % 
10 % Remarks: 
11 % 
12 % * This algorithm employs the topological sweep algorithm as described in      
13 %
14 %   Herbert Edelsbrunner, Leonidas J. Guibas, Topologically sweeping an arrangement, 
15 %   Journal of Computer and System Sciences, Volume 38, Issue 1, February 1989, Pages 165-194, ISSN 0022-0000
16 %
17 % * The runtime is quadratic in the number of particles nr_particles.
18 %
19 % * The source code is not optimized for speed.
20 %
21 % Date: 1 October 2013
22 % Author: Marcus Baum (baum@engineer.uconn.edu)
23 
24 if nargin == 0
25    nr_particles =200; 
26 end
27 
28 % Generate particles by sampling from a Gaussian mixture
29 MU = [2 2 3  4  0 1; 4  0 1 2 2 3];
30 SIGMA = cat(3,0.5*eye(6),0.3*eye(6));
31 weights =[1 2];
32 particles = random(gmdistribution(MU,SIGMA,weights),nr_particles);
33  
34 
35 % Calculate point estimates
36 MMSE_estimate = mean(particles);
37 MMOSPA_estimate = exact_MMOSPA_3D(particles');
38 
39 % Plotting
40 
41 figure;
42  
43 % Plot particles
44 plot3(particles(:,1), particles(:,2), particles(:,3),'o','MarkerEdgeColor','black', 'MarkerFaceColor','magenta','MarkerSize',4);
45 hold on
46 plot3(particles(:,4), particles(:,5),particles(:,6),'o','MarkerEdgeColor','black', 'MarkerFaceColor','blue', 'MarkerSize',4 );
47  
48 % Plot MMSE estimate
49 plot3(MMSE_estimate([1 4]),MMSE_estimate([2 5]),MMSE_estimate([3 6]),'x','MarkerSize',12,'LineWidth',3,'Color','red');
50   
51 % Plot MMOPSA estimate
52 plot3(MMOSPA_estimate([1 4]),MMOSPA_estimate([2 5]),MMOSPA_estimate([3 6]),'o','MarkerSize',12,'LineWidth',2,'Color','black','MarkerFaceColor','green');
53  
54 % Plot Legend
55 legend('Particles for Target 1', 'Particles for Target 2', 'MMSE Estimate','MMOSPA Estimate');
56 
57 axis equal
58 xlabel('x');
59 ylabel('y');
60 zlabel('z');
61 drawnow;
62 end
 1 function result = exact_MMOSPA_3D(x)
 2 %
 3 % Calculates the exact Minimum Mean Optimal Subpattern Assignment (MMOSPA) estimate for two 3D objects 
 4 % given by the particles x. The runtime is  quadratic in the number of particles. No degeneracy check
 5 % is performed, e.g., for duplicate particles. For details, see the paper
 6 % 
 7 % Marcus Baum, Peter Willett, Uwe D. Hanebeck, Calculating Some Exact MMOSPA Estimates for Particle Distributions,
 8 % Proceedings of the 15th International Conference on Information Fusion (Fusion 2012), Singapore, July, 2012.
 9 %
10 % Input:  Array of particles x with dimension (6,n), where n is the number of particles 
11 % Output: MMOSPA estimate, i.e., a 6-dimensional vector
12 %
13 % Remarks: 
14 % 
15 % * This algorithm employs the topological sweep algorithm as
16 %         described in 
17 %
18 %   Herbert Edelsbrunner, Leonidas J. Guibas, Topologically sweeping an arrangement, 
19 %   Journal of Computer and System Sciences, Volume 38, Issue 1, February 1989, Pages 165-194, ISSN 0022-0000
20 %
21 % * The source code is not optimized for speed.
22 %
23 % Date: 1 October 2013
24 % Author: Marcus Baum (baum@engineer.uconn.edu)
25 
26 nr_samples=size(x,2);
27 
28 %%% generate line arrangement based on samples
29 lines = zeros(nr_samples,2);
30 z=1;
31 for j= 1:nr_samples
32     proj = (x(1:3,j)-x(4:6,j));
33     proj = proj(1:3)/norm(proj(1:3));
34     lines(j,1)= -proj(1)/proj(2);
35     lines(j,2)= -(proj(3)*z)/proj(2);
36     if proj(2)<0
37         x(:,j)=x([4 5 6 1 2 3],j);
38     end
39 end
40 
41 %%% perform toplogical sweep
42 [sortedpermu cellChanges] = topologicalSweep(lines,0);
43 
44 x = x(:,sortedpermu);
45 M = nr_samples+2:-1:1;
46 
47 max_MOSPA = mean(x,2);
48 max_reward = max_MOSPA'*max_MOSPA ;
49 
50 current_Cut_MOSPA = zeros(6,nr_samples);
51 current_Cut_Reward = zeros(1,nr_samples);
52 
53 [current_Cut_MOSPA(:,1)  current_Cut_Reward(1,1)  max_MOSPA    max_reward ] = ...
54     updateMOSPA(max_MOSPA,max_reward, x(:,1), nr_samples, 1,max_MOSPA,max_reward);
55 
56 for i=2:nr_samples
57     [current_Cut_MOSPA(:,i)  current_Cut_Reward(i)  max_MOSPA    max_reward ] = ...
58         updateMOSPA(current_Cut_MOSPA(:,i-1), current_Cut_Reward(i-1), x(:,i), nr_samples, 1,max_MOSPA,max_reward);
59 end
60 
61 for i=1:length(cellChanges)
62     cI =cellChanges(i);
63     M([cI cI+1]) =  M([cI+1 cI]);
64     new_Cut_MOSPAcI = current_Cut_MOSPA(:,M(cI+1)-1) ;
65     new_Cut_RewardcI  =  current_Cut_Reward(M(cI+1)-1)  ;
66     [new_Cut_MOSPAcI1 new_Cut_RewardcI1 max_MOSPA max_reward ] = ...
67         updateMOSPA(current_Cut_MOSPA(:,M(cI)-1),current_Cut_Reward(M(cI)-1), x(:,M(cI+1)-1), nr_samples, 1,max_MOSPA,max_reward);
68     [new_Cut_MOSPAcI1 new_Cut_RewardcI1 max_MOSPA max_reward ] = ...
69         updateMOSPA(new_Cut_MOSPAcI1,new_Cut_RewardcI1,x(:,M(cI)-1),nr_samples, 0,max_MOSPA,max_reward);
70     current_Cut_MOSPA(:,M(cI)-1) =new_Cut_MOSPAcI;
71     current_Cut_Reward(M(cI)-1) = new_Cut_RewardcI;
72     current_Cut_MOSPA(:,M(cI+1)-1) =new_Cut_MOSPAcI1;
73     current_Cut_Reward(M(cI+1)-1) = new_Cut_RewardcI1;
74 end
75 result = max_MOSPA;
76 end
77 
78 
79 function [MOSPA reward max_MOSPA max_Reward] = updateMOSPA(MOSPA, reward, particle,n, newswitch,max_MOSPA,max_Reward)
80 if newswitch==1
81     switched_particle= particle([4 5 6 1 2 3])/n;
82     old_particle= particle/n;
83 else
84     switched_particle= particle/n;
85     old_particle= particle([4 5 6 1 2 3])/n;
86 end
87 temp = MOSPA-old_particle;
88 MOSPA =   temp + switched_particle;
89 reward =  temp'*temp + 2 * temp' *switched_particle +  switched_particle' * switched_particle;
90 if reward>max_Reward
91     max_MOSPA =  MOSPA;
92     max_Reward=reward;
93 end
94 
95 end
Download algorithm (2 files) as ZIP

Comments

Please login to post a comment.