... share your algorithms as a web service

Algorithm: External Approximation of Minkowski-Sum

Add as much inputarguments as you need.

Additionally you can add 2 more input parameters:
In the n-1th parameter you can specify the criterion to be optimized. This can either be 'trace' or 'determinant'.
In the last parameter you can use an optional weighting that will be used for optimalization ... (show more)
Tags: ellipsoid
Usage: Algorithm is public.
Viewed 26323 times, called 17 times
Empty star Empty star Empty star Empty star Empty star
0 votes
Florian Pfaff
08/21/2012 12:31 a.m. (version #1)

Run Algorithm

: Allow cached result?
Add varargin parameter - Remove varargin parameter

Please Wait

Computation is running...


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:

Result from Cache

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

Matlab log




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('', '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('')

    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


 1 function Xresult=minkExternalApprox(varargin)
 2 % Returns an external approximatization with (among those that can be
 3 % created using the formula) minizes a certain criterion (optimality is
 4 % not always guaranteed)
 5 % Syntax minkExternalApprox(Q1,Q2,...Qn,'trace',weight)
 6 %
 7 % @author Florian Pfaff
 8 % @date 2011
10     %test if weighting and criterion was passed
11     if nargin>2 && ischar(varargin{end-1})
12             criterion=varargin{end-1};
13             weighting=varargin{end};
14             varargin=varargin(1:end-2);
15     %test if only criterion was passed
16     elseif ischar(varargin{end})
17         criterion=varargin{end};
18         varargin=varargin(1:end-1);
19         weighting=eye(size(varargin{1}));
20     else
21         criterion='trace';
22         weighting=eye(size(varargin{1}));
23 %         criterion='volume';
24     end
25     %remove empty to prevent div / 0!
26     notEmpty=cellfun(@(X)max(max(X))~=0,varargin);
27     varargin=varargin(notEmpty);
28     %if only single matrix do not approx
29     if length(varargin)<=1
30         warning('ELLIPSOIDAPPROX:TOOFEW','At most one nonzero Matrix passed.')
31         Xresult=varargin{1};
32         return;
33     end
35     if strncmpi(criterion,'trace',3)||strncmpi(criterion,'spur',3)
36         q_i=(ones(length(varargin))-eye(length(varargin)))*cellfun(@(X)sqrt(trace(weighting*X*weighting')),varargin)'./(cellfun(@(X)sqrt(trace(weighting*X*weighting')),varargin)');
37         Xresult=sum(reshape(cell2mat(arrayfun(@(i){(1+q_i(i))*varargin{i}},1:length(varargin))),[size(varargin{1}),length(varargin)]),3);
38     elseif strncmpi(criterion,'volume',3)
39         if length(varargin)>2
40             error('Volume formula currently supports only 2 at a time');
41         end
42         %solution using syms
43         syms lambda real
44         lambdas=solve(det(varargin{1}-lambda*varargin{2}));
45         disp(real(double(lambdas)));
46         syms p positive        
47         pmin=real(double(solve(sum(1./(lambdas+p))-2/(p*(p+1)),'Real',true)));
48         Xresult=(pmin^-1+1)*varargin{1}+(pmin+1)*varargin{2};
50     else
51         error('Unknown mode');
52     end
54     %guarantee symmetric matrix
55     Xresult=triu(Xresult)+triu(Xresult)'-diag(diag(Xresult));
57  end
Download algorithm (1 file) as ZIP


Please login to post a comment.