Commit 2c4d7bce authored by Argyris Kalogeratos's avatar Argyris Kalogeratos

minor code improvements

parent 3a339480
......@@ -40,7 +40,7 @@ rngInfo = rng;
% a. Generate graph
graphPars.N = 100; % the size of graph to generate
graphPars.graphType = 'preferentialAttachment'; % available: 'erdosRenyi', 'preferentialAttachment', 'smallWorld', 'adjacencyMatrix'
graphPars.graphType = 'smallWorld'; % available: 'erdosRenyi', 'preferentialAttachment', 'smallWorld', 'adjacencyMatrix'
switch graphPars.graphType, % specific parameters needed for some random graph models
case 'erdosRenyi'
......
......@@ -20,7 +20,7 @@
% nodes and keep it this way throughout all the simulation.
% > 'MN': favors the treatment of the nodes with most neighbors (high degree nodes).
% > 'LN': favors the treatment of the nodes with least neighbors (low degree nodes).
% > 'SRAI' or 'LRSR': the Largest Reduction of Spectral Radius strategy.
% > 'LRSR': the Largest Reduction of Spectral Radius strategy.
% --<Dynamic strategies>--
% > 'MSN' : the treatment resources are given to the btot nodes that
% have the most susceptible neighbors (i.e. to the most viral nodes)
......@@ -53,48 +53,41 @@ function strategies = createStrategies (btot, varargin)
strategies = struct;
for strategyName=varargin
switch strategyName{1}
%-------------------------
% Baseline strategies
%-------------------------
if(strcmp(strategyName, 'NONE'))
strategies.NONE = @(idx, state) nullStrategy(idx, state);
end
if(strcmp(strategyName, 'RAND'))
strategies.RAND = @(idx, state) randomStrategy(idx, state, btot, true);
end
if(strcmp(strategyName, 'ALL'))
strategies.ALL = @(idx, state) allStrategy(idx, state);
end
case 'NONE'
strategies.NONE = @(idx, state) nullStrategy(idx, state);
case 'RAND'
strategies.RAND = @(idx, state) randomStrategy(idx, state, btot, true);
case 'ALL'
strategies.ALL = @(idx, state) allStrategy(idx, state);
%-------------------------
% Static strategies
%-------------------------
if(strcmp(strategyName, 'RANDFIXED'))
strategies.RANDFIXED = @(idx, state) staticStrategy(idx, state, @(G, infected) randperm(size(G,1))', btot, 'RANDMIXED', true);
end
if(strcmp(strategyName, 'MN'))
strategies.MN = @(idx, state) staticStrategy(idx, state, @(G, infected) full(sum(G, 2)), btot, 'MN', true);
end
if(strcmp(strategyName, 'LN'))
strategies.LN = @(idx, state) staticStrategy(idx, state, @(G, infected) -full(sum(G, 1))', btot, 'LN', true);
end
if(strcmp(strategyName, 'LRSR'))
strategies.LRSR = @(idx, state) staticStrategy(idx, state, @(G, infected) dropInMaxEigenValueApprox(G), btot, 'LRSR', true); % approximated version
end
case 'RANDFIXED'
strategies.RANDFIXED = @(idx, state) staticStrategy(idx, state, @(G, infected) randperm(size(G,1))', btot, 'RANDMIXED', true);
case 'MN'
strategies.MN = @(idx, state) staticStrategy(idx, state, @(G, infected) full(sum(G, 2)), btot, 'MN', true);
case 'LN'
strategies.LN = @(idx, state) staticStrategy(idx, state, @(G, infected) -full(sum(G, 1))', btot, 'LN', true);
case 'LRSR'
strategies.LRSR = @(idx, state) staticStrategy(idx, state, @(G, infected) dropInMaxEigenValueApprox(G), btot, 'LRSR', true); % approximated version
%-------------------------
% Dynamic strategies
%-------------------------
if(strcmp(strategyName, 'MSN'))
strategies.MSN = @(idx, state) preferentialStrategy(idx, state, @(idx, state) MSNcriterion(idx, state), btot);
end
if(strcmp(strategyName, 'LIN'))
strategies.LIN = @(idx, state) preferentialStrategy(idx, state, @(idx, state) LINcriterion(idx, state), btot);
end
if(strcmp(strategyName, 'LRIE'))
strategies.LRIE = @(idx, state) preferentialStrategy(idx, state, @(idx, state) LRIEcriterion(idx, state), btot);
end
end
case 'MSN'
%old code: strategies.MSN = @(idx, state) preferentialStrategy(idx, state, @(G, infected) G * (1 - infected), btot);
strategies.MSN = @(idx, state) preferentialStrategy(idx, state, @(idx, state) MSNcriterion(idx, state), btot);
case 'LIN'
%old code: strategies.LIN = @(idx, state) preferentialStrategy(idx, state, @(G, infected) - G * infected, btot);
strategies.LIN = @(idx, state) preferentialStrategy(idx, state, @(idx, state) LINcriterion(idx, state), btot);
case 'LRIE'
strategies.LRIE = @(idx, state) preferentialStrategy(idx, state, @(idx, state) LRIEcriterion(idx, state), btot);
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment