Skip to content

Instantly share code, notes, and snippets.

@machkouroke
Created April 14, 2023 23:11
Show Gist options
  • Save machkouroke/c74a8ba2903977b3a4034c957866630c to your computer and use it in GitHub Desktop.
Save machkouroke/c74a8ba2903977b3a4034c957866630c to your computer and use it in GitHub Desktop.
using ProgressBars
using Plots
using Random
Random.seed!(1245)
include("utilities.jl")
include("plotter.jl")
include("solver.jl")
function main()
n::Int64 = 8
pop_size::Int64 = 15
n_gen = 200
n_parents = 2
n_mates = 5
selection_method = "roulette"
solver = NqueenSolver(n=n, pop_size=pop_size, n_gen=n_gen, n_mates=n_mates, selection_method=selection_method, n_parents=n_parents)
max_fitness, min_fitness, avg_fitness, best_value = solve(solver)
board = plot_chromosome(best_value, n)
evolution = plot_evolution(max_fitness, min_fitness, avg_fitness)
p = plot(board, evolution, layout=(1, 2), size=(1000, 500))
savefig(p, "n_queens.png")
display(p)
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment