Coder Social home page Coder Social logo

nsgaii.jl's People

Contributors

gsoleilhac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nsgaii.jl's Issues

undef not defined

I'm attempting to execute the example code (knapsack), but I get this error:

ERROR: LoadError: UndefVarError: undef not defined
Stacktrace:
[1] (::Atom.##110#114{String,String})() at C:\Users\leona\AppData\Local\JuliaPro-0.6.2.2\pkgs-0.6.2
.2\v0.6\Atom\src\eval.jl:104
[2] withpath(::Atom.##110#114{String,String}, ::String) at C:\\\\\\\\\\\\\\\\\\\
\\\\\\\\\Users\leona\AppData\Local\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\CodeTools\src\utils.jl
:30
[3] withpath(::Function, ::String) at C:\Users\leona\AppData\Local\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0
.6\Atom\src\eval.jl:38
[4] hideprompt(::Atom.##109#113{String,String}) at C:\Users\leona\AppData\Local\JuliaPro-0.6.2.2\pk
gs-0.6.2.2\v0.6\Atom\src\repl.jl:65
[5] macro expansion at C:\Users\leona\AppData\Local\JuliaPro-0.6.2.2\pkgs-0.6.2.2\v0.6\Atom\src\eva
l.jl:99 [inlined]
[6] (::Atom.##108#112{Dict{String,Any}})() at .\task.jl:80
while loading C:\Users\leona\Downloads\knapsack_test.jl, in expression starting on line 13

Checking the source code, the problem seems to be in 'functions.jl' line 5 where you write undef, which isn't indeed declared anywhere. What's that? Is it a way to say 'not implemented yet'? Am I missing something?

ReadMe 1st example doesn't work with Julia 1.2

With some updates, the readme doesn't quite work as written. Specifically, the calls to bitrand need to be changed, and you need to call using Random, LinearAlgebra

The following worked for me:
`using NSGAII
using Random
using LinearAlgebra
n = 20 #Number of items
p1 = [77,94,71,63,96,82,85,75,72,91,99,63,84,87,79,94,90,60,69,62] #Coeffs objective 1
p2 = [65,90,90,77,95,84,70,94,66,92,74,97,60,60,65,97,93,60,69,74] #Coeffs objective 2
w = [80,87,68,72,66,77,99,85,70,93,98,72,100,89,67,86,91,79,71,99] #Items weights
c = 900 #Knapsack capacity

rng = MersenneTwister(1234);
popsize = 100
nbgen = 200

init() = bitrand(rng, n) #our genotype is a binary vector of size n, initialized randomly
z(x) = dot(x, p1), dot(x, p2) #and our objectives are the sum of the items we pick

function CV(x)
sumW = dot(x, w)
return sumW <= c ? 0 : sumW - c
end

#We can now call
result = nsga_max(popsize, nbgen, z, init, fCV = CV)
`

Requesting Parallel computation to speed up gene evaluation.

The model I am using means that the cost of evaluating genes is very high. Can there be an argument to nsga that allows you to use pmap for the parts of nsga that involve computing new genes? If I try to implement this on my fork which parts of NSGAII.jl should I edit?

Possible division by zero in crowding distance assignment

Hello, while inspecting your code I noticed a potential flaw in the crowding distance assignment function.
I see that you split crowding_distance_assignement! in two cases: one for when you have only 2 objective functions, the other for more than 2.
I assume this is an optimization to avoid a sort in the first case, which is fine and makes sense.
However, I think that you forgot to check if pop[1].y[1] != pop[end].y[1] and if pop[1].y[2] != pop[end].y[2] in the first case, which could become a source of zero division errors when the whole population shares the same fitness for at least one objective.
In the second case, instead, you perform the check (line 112) and that's good.
I think it's just an oversight, because I see no reason to assume pop[end].y[1] always different from pop[1].y[1]

PS: I also suggest to rename 'assignement' into 'assignment'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.