Home > Mateda2.0 > functions > ising-model > EvalIsing.m

EvalIsing

PURPOSE ^

[r] = evalIsing(ind)

SYNOPSIS ^

function [r] = evalIsing(ind)

DESCRIPTION ^

 [r] = evalIsing(ind)
  evalIsing : Gives the value of the Ising model for zero-one
                        vector configuration. Requires that lattice and inter be previously
                        defined as global structures.
 INPUT
 ind: the individual (vector) which represents a matrix of values for the spins
 lattice, inter: Structures with the lattice J and the interaction values between spins
 OUTPUT
 The evaluation of the Ising model given a problem instance and a
 individual

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [r] = evalIsing(ind)
0002 % [r] = evalIsing(ind)
0003 %  evalIsing : Gives the value of the Ising model for zero-one
0004 %                        vector configuration. Requires that lattice and inter be previously
0005 %                        defined as global structures.
0006 % INPUT
0007 % ind: the individual (vector) which represents a matrix of values for the spins
0008 % lattice, inter: Structures with the lattice J and the interaction values between spins
0009 % OUTPUT
0010 % The evaluation of the Ising model given a problem instance and a
0011 % individual
0012 %
0013 % Last version 8/26/2008. Carlos Echegoyen and Roberto Santana (roberto.santana@ehu.es)
0014 
0015 global Isinglattice
0016 global Isinginter
0017 r = 0;
0018 for i=1:size(Isinglattice,1)
0019     if Isinglattice(i,1) > 0
0020         for j=2:(Isinglattice(i,1) + 1)
0021             if i < Isinglattice(i,j)
0022                 auxr = 2 * (ind(i) == ind(Isinglattice(i,j))) - 1;
0023                 r = r + (auxr * Isinginter(i,j-1));
0024             end
0025         end
0026     end
0027 end
0028 
0029 r = -1*r;

Generated on Fri 04-Dec-2009 13:38:29 by m2html © 2003