We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f5ca27d + e48a553 commit e7180a1Copy full SHA for e7180a1
algorithms/Searching/random_search.m
@@ -0,0 +1,24 @@
1
+%% Random Search Algorithm (Pure Random Search Algorithm)
2
+
3
+% This code finds the minimum of f(x) = x(1)^2 + x(2)^2
4
+% in which -5 < x(i) < 5
5
+% This function is a convex and the minimum is at (0,0)
6
+% The RSA is the simplest algorithm to solve optimization problem
7
+% it is not efficient and it sometimes cannot solve the problem
8
9
+clc
10
+close all
11
+clear all
12
+dim=2;
13
+popsize=100;
14
+ftarget=0.01;
15
+numIter=100;
16
+ObjFun=@(x) sum(x.^2);
17
+for i=1:numIter
18
+ candidate=10*rand(dim,popsize)-5;
19
+ best,=min(feval(ObjFun,candidate));
20
+ if best <= ftarget
21
+ break;
22
+ end
23
+end
24
+disp(best);
0 commit comments