Home > Mateda2.0 > local_optimization > Greedy_search_OffHP.m

# Greedy_search_OffHP

## PURPOSE

[NewPop,NumbEvals] = Greedy_search_OffHP(k,Pop,FunVal,local_opt_params)

## SYNOPSIS

function[NewPop,NewFunVal,NumbEvals] = Greedy_search_OffHP(k,Pop,FunVal,local_opt_params)

## DESCRIPTION

     [NewPop,NumbEvals] =  Greedy_search_OffHP(k,Pop,FunVal,local_opt_params)
     Greedy_search_OffHP: Greedy  local optimization method for the Off
     lattice HP model
     INPUT
     k: Current generation
     Pop: Population
     FunVal: Function values for each individual in the population
     trials:  = cell2num(local_opt_params{1}(1)) number of local optimization
             moves for each solution
     OUTPUT:
     NewPop: Population after local search
     NewFunVal: Function values for the population optimized
     NumbEvals: Number of evaluations made during the local optimization step

## CROSS-REFERENCE INFORMATION

This function calls:

- EvaluateOffHPProtein [Evals] = EvaluateOffHPProtein(Pop)
- Trigom_repairing [NewPop] = Trigomn_repairing(Pop,RangeValues,repairing_params)

This function is called by:

## SOURCE CODE

    0001 function[NewPop,NewFunVal,NumbEvals] =  Greedy_search_OffHP(k,Pop,FunVal,local_opt_params)
    0002 % [NewPop,NumbEvals] =  Greedy_search_OffHP(k,Pop,FunVal,local_opt_params)
    0003 % Greedy_search_OffHP: Greedy  local optimization method for the Off
    0004 % lattice HP model
    0005 % INPUT
    0006 % k: Current generation
    0007 % Pop: Population
    0008 % FunVal: Function values for each individual in the population
    0009 % trials:  = cell2num(local_opt_params{1}(1)) number of local optimization
    0010 %         moves for each solution
    0011 % OUTPUT:
    0012 % NewPop: Population after local search
    0013 % NewFunVal: Function values for the population optimized
    0014 % NumbEvals: Number of evaluations made during the local optimization step
    0015
    0016 trials = cell2num(local_opt_params{1}(1));
    0017
    0018 N = size(Pop,1);
    0019 NumbVar = size(Pop,2);
    0020 NumbEvals = 0;
    0021 for i=1:N
    0022  BestX = Pop(i,:);
    0023  BestV = FunVal(i,1);
    0024  for j=1:trials,
    0025     NewX = BestX;
    0026     pos_a = fix(NumbVar*rand) + 1;
    0027     pos_b = fix(NumbVar*rand) + 1;
    0028     %inc_a  = pi*((fix(90*rand)+1)/90);
    0029     %inc_b  = pi*((fix(90*rand)+1)/90);
    0030     %NewX(pos_a) = BestX(pos_a) + (1 + 2*(fix(2*rand)-1))*inc_a;
    0031     %NewX(pos_b) = BestX(pos_b) + (1 + 2*(fix(2*rand)-1))*inc_b;
    0032     NewX(pos_a) = 2*pi*rand;
    0033     NewX(pos_b) = 2*pi*rand;
    0034     NewV = EvaluateOffHPProtein(NewX);
    0035     %if(NewV >= BestV)
    0036     if( (NewV - BestV) > -0.01)
    0037       BestV = NewV;
    0038       BestX = NewX;
    0039       %[i,j,BestV]
    0040     end
    0041  end,
    0042  %[i,FunVal(i,1),BestV]
    0043  NewPop(i,:) = BestX;
    0044  NewFunVal(i,1) = BestV;
    0045  NumbEvals = NumbEvals + trials;
    0046 end,
    0047 RangeValues =  [zeros(1,NumbVar);2*pi*ones(1,NumbVar)];
    0048 [NewPop] =   Trigom_repairing(NewPop,RangeValues,{});
    0049
    0050
    0051