Giter Club home page Giter Club logo

Comments (5)

jmejia8 avatar jmejia8 commented on August 18, 2024

Use the logger argument in optimize method.

function logger(status)
    @info "Iteration $(status.iteration)"
    # get non-dominated solutions
    P = Metaheuristics.get_non_dominated_solutions(status.population)
    X = positions(P) # decisions variables
    FX = fvals(P) # objective function values
    display(FX)
end

f, bounds, _ = Metaheuristics.TestProblems.ZDT1();
res = optimize(f, bounds, NSGA2(), logger=logger)

See optimize, Metaheuristics.get_non_dominated_solutions, and the API References for more details.

from metaheuristics.jl.

licheng0794 avatar licheng0794 commented on August 18, 2024

Use the logger argument in optimize method.

function logger(status)
    @info "Iteration $(status.iteration)"
    # get non-dominated solutions
    P = Metaheuristics.get_non_dominated_solutions(status.population)
    X = positions(P) # decisions variables
    FX = fvals(P) # objective function values
    display(FX)
end

f, bounds, _ = Metaheuristics.TestProblems.ZDT1();
res = optimize(f, bounds, NSGA2(), logger=logger)

See optimize, Metaheuristics.get_non_dominated_solutions, and the API References for more details.

Thank you.

Metaheuristics.get_non_dominated_solutions(status.population) returns the current non dominated points from the current population. How if I want all of the non dominated points so far?

fval requires a repeat evaluation. If the function is expensive, fval takes very long. Is there an alternative which directly access the function values of the non-dominated points saved?

from metaheuristics.jl.

jmejia8 avatar jmejia8 commented on August 18, 2024

How if I want all of the non dominated points so far?

Depending on the algorithm, get_non_dominated_solutions will return all the non-dominated solutions found so far (until density estimator is used to removing solutions). Try using (assuming you're using NSGA2) NSGA2(options=Options(store_convergence=true)), which will save (in res.convergence) the status at each iteration.

Another option is to use an external archive to save the results using the logger function.

archive = []
logger(status) = push!(archive, status.population)
res = optimize(f, bounds, NSGA2(), logger=logger)
iteration = 1
display(fvals(archive[iteration]))

fval requires a repeat evaluation

Actually fval and fvals do not require re-evaluating solutions due to function values are stored in status.population.

from metaheuristics.jl.

licheng0794 avatar licheng0794 commented on August 18, 2024

Actually fval and fvals do not require re-evaluating solutions due to function values are stored in status.population.

I indeed tested the function 'fval' and found that it took much long so I supposed it did re-evaluate the function. Can you please confirm that? Thank you.

from metaheuristics.jl.

jmejia8 avatar jmejia8 commented on August 18, 2024

I'm pretty sure that Metaheuristics.fval(sol) is not re-evaluating sol to provide an output. You can see the function definition by typing:

@edit fval(res.population[1])

I'm assuming you did not overwrite the fval method.

from metaheuristics.jl.

Related Issues (20)

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.