forked from ICB-DCM/PESTO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meigoDummy.m
45 lines (43 loc) · 1.07 KB
/
meigoDummy.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function varargout = meigoDummy(theta, fun, varargin)
% Objective function wrapper for MEIGO / PSwarm / ... which need objective
% function *file*name* and cannot use function handles directly.
%
% Parameters:
% theta: parameter vector
% fun: objective function handle
% varargin:
%
% Return values:
% f: Objective function value
if(nargin(fun) == 1)
switch nargout
case 1
[f] = fun(theta);
varargout{1} = f;
case 2
[f,g] = fun(theta);
varargout{1} = f;
varargout{2} = g;
case 3
[f,g,h] = fun(theta);
varargout{1} = f;
varargout{2} = g;
varargout{3} = h;
end
else
switch nargout
case 1
[f] = fun(theta, varargin);
varargout{1} = f;
case 2
[f,g] = fun(theta, varargin);
varargout{1} = f;
varargout{2} = g;
case 3
[f,g,h] = fun(theta, varargin);
varargout{1} = f;
varargout{2} = g;
varargout{3} = h;
end
end
end