You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Links on MD modified, mainly image hyperlink url, now when click on image it opens the image instead of go to the main repo (like before). Also the alt texts on links in spanish MD was changed to spanish. The main links on the top block (about where to read the original/another language article) wash changed; only the Medium.com link (the original article link) is pending
Copy file name to clipboardExpand all lines: Article/LRPS-EN.md
+22-21Lines changed: 22 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,12 @@
1
1
# Proposal of Selection Method for Evolutionary Algorithms based on Logarithmic Scale ponderation
2
+
2
3
### By Alejandro Ramos @arhcoder
3
4
4
5
<hr>
5
6
6
-
#### 📓 Read the original article [here](http://google.com"here").
7
-
#### 🔣 Lee este artículo en [español](http://google.com"español").
8
-
#### ⭐ Give a star to [this repository](https://github.com/arhcoder/LRPS-Algorithm"this repository").
7
+
#### 📓 Read the original article [here](https://medium.com/@arhcoder"Medium.com article link").
8
+
#### 🔣 Lee este artículo en [español](https://github.com/arhcoder/LRPS-Algorithm/blob/master/Article/LRPS-ES.md"Artículo en español").
9
+
#### ⭐ Give a star to [this repository](https://github.com/arhcoder/LRPS-Algorithm"Go and click on the star").
9
10
10
11
<hr>
11
12
@@ -18,7 +19,7 @@ When working with models that require selection mechanisms, it is common to use
18
19
19
20
The idea behind this proposal is born from the analysis of phenomena for which there are events with a greater frequency of being present, but for which the factor that determines these magnitude is not known. Being concrete, ***LRPS*** originates from my own attempt to replicate the composition of music through genetic algorithms with randomness, being clear the fact that depending on the style of music, genre, era, etc., certain composition patterns are more common; for example: 4/4 time signature, long or short notes, simple or complex harmonies, etc. Popular music tends to have with more frequency the 4/4 signature, and only major-minor chords, slow voice melodies, relaxed rhythms, among others; It is then that in order to try to replicate the composition of popular music, we could consider these characteristics as the most common, but without neglecting the fact that it is possible to have more variety of decision.
20
21
21
-
**Note:** The above mentioned project of music composition with genetic algorithms can be found at: **[github.com/arhcoder/M.I.A](https://github.com/arhcoder/M.I.A"github.com/arhcoder/M.I.A").**
22
+
**Note:** The above mentioned project of music composition with genetic algorithms can be found at: **[github.com/arhcoder/M.I.A](https://github.com/arhcoder/M.I.A"Repository of M.I.A project").**
22
23
23
24
<br>
24
25
@@ -33,17 +34,17 @@ If for decision-making in a model there are biases and weights without a number
33
34
34
35
In the model it has been decided that Cookies n’ cream flavor is the favorite, so its selection should be more frequent, followed by strawberry, chocolate, etc. The important issue is that there is no a tangible number that allows determining this importance bias with respect to the other flavors, it is simply known that flavors are preferred more as they are higher on the top. The logarithmic scale can provide a growth ratio based on its exponential mathematical nature:
35
36
36
-
[](https://github.com/arhcoder/LRPS-Algorithm"Comparison between linear and logarithmic scale")
37
+
[](https://github.com/arhcoder/LRPS-Algorithm/blob/master/Images/Scales.png?raw=true"Comparison between linear and logarithmic scale")
37
38
38
39
A loose representation of what is the difference between linear and logarithmic scales looks like is shown in the image above; if we take it as an example, we could understand this decision algorithm as placing a point randomly in any of the two scales, where the space between two divisions represents an object to select. For the case of the linear scale, the probability of finding the object between **0 and 1** is the same as that of the object between **1 and 2,** or **2 and 3.** On the other hand, with the logarithmic scale, the probability of falling into the object between **0 and 1** is very different from that of the object between **5 and 6.**
39
40
40
41
Using real data for the example of choosing an ice cream flavor, we would have the following scales comparison:
41
42
42
-
[](https://github.com/arhcoder/LRPS-Algorithm"Linear and logarithmic scales for five flavors")
43
+
[](https://github.com/arhcoder/LRPS-Algorithm/blob/master/Images/Flavors.png?raw=true"Linear and logarithmic scales for five flavors")
43
44
44
45
This is what the ***LRPS*** algorithm scale looks compared to a roulette algorithm. If we throw a random point in this space; we would obtain the decisions for both types of algorithms, which would be:
45
46
46
-
[](https://github.com/arhcoder/LRPS-Algorithm"Selection example for five flavors on linear and logarithmic scales")
47
+
[](https://github.com/arhcoder/LRPS-Algorithm/blob/master/Images/Selection.png?raw=true"Selection example for five flavors on linear and logarithmic scales")
47
48
48
49
-**(🍫) Chocolate for a roulette algorithm.**
49
50
-**(🍓) Strawberry: for the LRPS algorithm.**
@@ -53,23 +54,23 @@ As the space of the strawberry is larger than the chocolate ones, it is more lik
53
54
<br>
54
55
55
56
### Math
56
-
The way to build a logarithmic scale adapted to the ***n*** quantity of objects to be selected is possible through a **P set of points on a Cartesian axis** in which each point delimits the selection space of each of the n elements of the list, using the following formula:
57
+
The way to build a logarithmic scale adapted to the ***n*** quantity of objects to be selected is possible through a ***P* set of points on a Cartesian axis** in which each point delimits the selection space of each of the n elements of the list, using the following formula:
57
58
58
-
[](https://github.com/arhcoder/LRPS-Algorithm"Formula to build a n spaces logarithmic scale")
59
+
[](https://github.com/arhcoder/LRPS-Algorithm/blob/master/Images/Formula.png?raw=true"Formula to build a n spaces logarithmic scale")
59
60
60
61
That is, given the same case of building the scale on a Cartesian axis, with ***n*** number of spaces (objects) and therefore ***n*** number of division points, the distance between each point ***i*** and the ***origin*** (coordinate (0, 0)) is given by the formula:
61
62
62
-
[](https://github.com/arhcoder/LRPS-Algorithm"Formula for distances on a n spaces logarithmic scale")
63
+
[](https://github.com/arhcoder/LRPS-Algorithm/blob/master/Images/Distance.png?raw=true"Formula for distances on a n spaces logarithmic scale")
63
64
64
65
If it is wanted to find the coordinate of point 1, for the example of five ice cream flavors (with n = 5), the coordinate would be:
65
66
66
-
[](https://github.com/arhcoder/LRPS-Algorithm"Calculation of the space of a point 1 in logarithmic scale with n = 5")
67
+
[](https://github.com/arhcoder/LRPS-Algorithm/blob/master/Images/Point.png?raw=true"Calculation of the space of a point 1 in logarithmic scale with n = 5")
67
68
68
69
So, to find all the points needed to build the logarithmic scale of five objects:
69
70
70
-
[](https://github.com/arhcoder/LRPS-Algorithm"Calculation of the five points of a logarithmic scale")
71
+
[](https://github.com/arhcoder/LRPS-Algorithm/blob/master/Images/Points.png?raw=true"Calculation of the five points of a logarithmic scale")
**Note: The use of the Cartesian axis is unnecessary for the algorithm, since it is only necessary to know the distance between the origin and any other point on the scale; so only the distance formula will be necessary: dᵢ = nlogₙ₊₁(i+1).**
75
76
@@ -78,7 +79,7 @@ So, to find all the points needed to build the logarithmic scale of five objects
78
79
### Algorithm:
79
80
The pseudocode of the selection algorithm is shown below:
A list of objects is received as input from which the value of ***n*** is obtained as the number of objects in the selection. A couple of stopping cases occur when the list is empty or contains just one element, otherwise proceeds with the rest of the algorithm, where a random decimal number between 0 and ***n*** is obtained, and a loop for 1 to ***n*** is started.
84
85
@@ -93,27 +94,27 @@ Doing count tests for the decisions made by the algorithm in order to check the
**It can be verified that the shape of a logarithm curve is obtained.**
115
116
116
-
**Note:** For ***random*** numbers generation, the random function of the **64-bit Python v.3.11 core** was used. The counting-graphing script as well as the LRPS algorithm can be found on [**this repository**](https://github.com/arhcoder/LRPS-Algorithm"this repository").
117
+
**Note:** For ***random*** numbers generation, the random function of the **64-bit Python v.3.11 core** was used. The counting-graphing script as well as the LRPS algorithm can be found on [**this repository**](https://github.com/arhcoder/LRPS-Algorithm"Main repository of LRPS Algorithm").
117
118
118
119
<br>
119
120
@@ -122,7 +123,7 @@ This is just a proposal of algorithm, it may be useful in; for example, decision
122
123
123
124
In the event that for a specific problem it is desired that two or more objects have the same selection probability, it can be considered –for this implementation– that these objects are included in a data structure that contains them as **ONE** single object, so that if the algorithm chooses them, it will throw the objects as a whole, later and by means of a roulette-type decision (such as the linear scale) one of these can be chosen.
124
125
125
-
Check the algorithm code from the **main repository** at [**github.com/arhcoder/LRPS-Algorithm**](https://github.com/arhcoder/LRPS-Algorithm"github.com/arhcoder/LRPS-Algorithm"), **any collaboration and/or improvement proposal (pull request)** will be welcome, just like a **GitHub star.**
126
+
Check the algorithm code from the **main repository** at [**github.com/arhcoder/LRPS-Algorithm**](https://github.com/arhcoder/LRPS-Algorithm"Main repository of LRPSAlgorithm"), **any collaboration and/or improvement proposal (pull request)** will be welcome, just like a **GitHub star.**
126
127
127
128
Write to me at **arhcoder@gmail.com** for any query, or if this contribution was useful to you in any application. Also look for me on social media as **@arhcoder.**
0 commit comments