[ListFactors] = CreateListFactorsCircularNK(NumberVar,k) CreateListFactorsCircularNK: Creates the structure of an instance of the NK landscape where each variable depends on its k/2 previous and k/2 subsequent neighbors in a circular way INPUTS NumbVar: Number of variables k: Number of neighbors (0<k<NumbVar) OUTPUTS ListFactors: Each cell {i} stores the current variable (i), and its k neighbors Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0001 function [ListFactors] = CreateListFactorsCircularNK(NumberVar,k) 0002 % [ListFactors] = CreateListFactorsCircularNK(NumberVar,k) 0003 % CreateListFactorsCircularNK: Creates the structure of an instance of the NK landscape 0004 % where each variable depends on its k/2 0005 % previous and k/2 subsequent neighbors in a 0006 % circular way 0007 % INPUTS 0008 % NumbVar: Number of variables 0009 % k: Number of neighbors (0<k<NumbVar) 0010 % OUTPUTS 0011 % ListFactors: Each cell {i} stores the current variable (i), and its k neighbors 0012 % 0013 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es) 0014 for i=1:NumberVar, 0015 ActualNeighbors = [i-k/2:i-1,i+1:i+k/2]; 0016 ind = find(ActualNeighbors<=0); 0017 if ~isempty(ind) 0018 ActualNeighbors(ind) = ActualNeighbors(ind) + NumberVar; 0019 end 0020 ind = find(ActualNeighbors>NumberVar); 0021 if ~isempty(ind) 0022 ActualNeighbors(ind) = ActualNeighbors(ind) - NumberVar; 0023 end 0024 ListFactors{i} = [i,ActualNeighbors]; 0025 end,