Home > Mateda2.0 > functions > generators > CreateListFactorsNK.m

# CreateListFactorsNK

## PURPOSE

[ListFactors] = CreateListFactorsNK(NumberVar,k)

## SYNOPSIS

function [ListFactors] = CreateListFactorsNK(NumberVar,k)

## DESCRIPTION

     [ListFactors] =  CreateListFactorsNK(NumberVar,k)
     CreateListFactorsNK:   Creates the structure of an instance of the NK random landscape
                            The neihbors for each of the variables are
                            randomly selected
     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)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- AllNKInstances AllNKInstances(NumberVar,k,Number_Inst,nam)

## SOURCE CODE

    0001 function [ListFactors] =  CreateListFactorsNK(NumberVar,k)
    0002 % [ListFactors] =  CreateListFactorsNK(NumberVar,k)
    0003 % CreateListFactorsNK:   Creates the structure of an instance of the NK random landscape
    0004 %                        The neihbors for each of the variables are
    0005 %                        randomly selected
    0006 % INPUTS
    0007 % NumbVar: Number of variables
    0008 % k: Number of neighbors (0<k<NumbVar)
    0009 % OUTPUTS
    0010 % ListFactors: Each  cell {i} stores the current variable (i), and its k neighbors
    0011 %
    0012 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0013
    0014 for i=1:NumberVar,
    0015  PotentialNeighbors = randperm(NumberVar-1);
    0016  aux = [[1:i-1],[i+1:NumberVar]];
    0017  PotentialNeighbors = aux(PotentialNeighbors);
    0018  ActualNeighbors = PotentialNeighbors(1:k);
    0019  ListFactors{i} = [i,ActualNeighbors];
    0020 end,