Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
danymukesha committed Feb 9, 2024
1 parent d3e4191 commit 626248c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ knitr::opts_chunk$set(
[![R-CMD-check](https://github.com/danymukesha/genetic.algo.optimizeR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/danymukesha/genetic.algo.optimizeR/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/genetic.algo.optimizeR)](https://CRAN.R-project.org/package=genetic.algo.optimizeR)
[![Launch binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/danymukesha/genetic.algo.optimizeR/main)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svge)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
<!-- badges: end -->

The goal of `genetic.algo.optimizeR` is to optimize the function $f(x) = x^2 - 4x + 4$ using a genetic algorithm. The function represents a simple quadratic equation, and the goal is to find the value of $x$ that minimizes the function.
Expand Down
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ status](https://www.r-pkg.org/badges/version/genetic.algo.optimizeR)](https://CR
[![Launch
binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/danymukesha/genetic.algo.optimizeR/main)
[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svge)](https://lifecycle.r-lib.org/articles/stages.html#stable)
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
<!-- badges: end -->

The goal of `genetic.algo.optimizeR` is to optimize the function
Expand Down Expand Up @@ -76,7 +76,7 @@ population <- initialize_population(population_size = 3, min = 0, max = 3)
print("Initial Population:")
#> [1] "Initial Population:"
print(population)
#> [1] 0 1 3
#> [1] 1 3 2

generation <- 0 # Initialize generation/reputation counter

Expand Down Expand Up @@ -112,25 +112,17 @@ while (TRUE) {
print(population)
}
#> [1] "Evaluation:"
#> [1] 4 1 1
#> [1] "Selection:"
#> [1] 1 3
#> [1] "Crossover and Mutation:"
#> [1] 2 2
#> [1] "Replacement:"
#> [1] 2 1 3
#> [1] "Evaluation:"
#> [1] 0 1 1
#> [1] 1 1 0
#> [1] "Selection:"
#> [1] 2 1
#> [1] "Crossover and Mutation:"
#> [1] 2 2
#> [1] 1 1
#> [1] "Replacement:"
#> [1] 2 1 2
#> [1] 1 1 2
#> [1] "Evaluation:"
#> [1] 0 1 0
#> [1] 1 1 0
#> [1] "Selection:"
#> [1] 2 2
#> [1] 2 1
#> [1] "Crossover and Mutation:"
#> [1] 2 2
#> [1] "Replacement:"
Expand All @@ -140,7 +132,7 @@ while (TRUE) {
#> [1] "Termination Condition Reached: All individuals have fitness close to zero."

print(paste("Total generations/reputations:", generation))
#> [1] "Total generations/reputations: 4"
#> [1] "Total generations/reputations: 3"
```

The above example illustrates the process of a genetic algorithm, where
Expand Down

0 comments on commit 626248c

Please sign in to comment.