Skip to content

Commit

Permalink
Update optimization module
Browse files Browse the repository at this point in the history
  • Loading branch information
americocunhajr committed Jul 17, 2024
1 parent d1f8d69 commit 063d1c7
Show file tree
Hide file tree
Showing 23 changed files with 2,831 additions and 1,099 deletions.
Binary file modified STONEHENGE-1.0/.DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions STONEHENGE-1.0/HarvesterOpt-1.0/CrossEntropyOpt_Example.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

% -----------------------------------------------------------------
% One-dimensional optimization with the Cross-entropy method
%
% Example from:
% Reuven Y. Rubinstein, Dirk P. Kroese
% The Cross-Entropy Method: A Unified Approach to
% Combinatorial Optimization, Monte-Carlo Simulation,
% and Machine Learning
% Springer-Verlag, 2004.
% -----------------------------------------------------------------

clc
clear
close all

S = inline('exp(-(x-2).^2) + 0.8*exp(-(x+2).^2)');

mu = -6;
sigma = 10;
Nel = 10;
N = 100;
eps = 1E-8;
tic
t=0;

while sigma > eps
t = t+1;
x = mu + sigma*randn(N,1);
SX = S(x);
sortSX = sortrows([x SX],2);
Xel = sortSX((N - Nel + 1):N,1);
mu = mean(Xel);
sigma = std(Xel);
fprintf('%g %6.9f %6.9f %6.9f \n', t, S(mu),mu, sigma)
end

mu
toc
Loading

0 comments on commit 063d1c7

Please sign in to comment.