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

# AllNKInstances

## PURPOSE

AllNKInstances(NumberVar,k,Number_Inst,nam)

## SYNOPSIS

function AllNKInstances(NumberVar,k,Number_Inst,nam)

## DESCRIPTION

     AllNKInstances(NumberVar,k,Number_Inst,nam)
     AllNKInstances:   Generates Number_Inst instances of a random landscape model with
                       NumberVars variables and k random neighbors for each variable
                       The structure and function of the instances are saved
                       in files beginning with 'nam'
     We assume all nodes have cardinality 2
     INPUTS
     NumbVar: Number of variables
     k: Number of neighbors (0<k<NumbVar)
     Number_Inst: Number of instances to be generated
     nam: prefix name for the files that will store the structure and values
     of the functions

     Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

- CreateListFactorsNK [ListFactors] = CreateListFactorsNK(NumberVar,k)
- CreateRandomFunctions [Table] = CreateRandomFunctions(ListFactors,Card)
- SaveFunctionStructure SaveFunctionStructure(filename,NumberVar,ListFactors,Card)
- SaveFunctionValues [] = SaveFunctionValues(filename,NumberVar,ListFactors,Table)

This function is called by:

## SOURCE CODE

    0001 function  AllNKInstances(NumberVar,k,Number_Inst,nam)
    0002 % AllNKInstances(NumberVar,k,Number_Inst,nam)
    0003 % AllNKInstances:   Generates Number_Inst instances of a random landscape model with
    0004 %                   NumberVars variables and k random neighbors for each variable
    0005 %                   The structure and function of the instances are saved
    0006 %                   in files beginning with 'nam'
    0007 % We assume all nodes have cardinality 2
    0008 % INPUTS
    0009 % NumbVar: Number of variables
    0010 % k: Number of neighbors (0<k<NumbVar)
    0011 % Number_Inst: Number of instances to be generated
    0012 % nam: prefix name for the files that will store the structure and values
    0013 % of the functions
    0014 %
    0015 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0016
    0017 Card = 2*ones(1,NumberVar);
    0018
    0019 for i=1:Number_Inst
    0020  [ListFactors] =  CreateListFactorsNK(NumberVar,k)
    0021  extfilename = [nam,'_str_N',num2str(NumberVar),'_k',num2str(k),'Inst_',num2str(i),'.txt'];
    0022  SaveFunctionStructure(extfilename,NumberVar,ListFactors,Card);
    0023  [Table] = CreateRandomFunctions(ListFactors,Card)
    0024   extfilename = [nam,'_fnt_N',num2str(NumberVar),'_k',num2str(k),'Inst_',num2str(i),'.txt'];
    0025  SaveFunctionValues(extfilename,NumberVar,ListFactors,Table);
    0026 end