Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in write_results #231

Open
floswald opened this issue Feb 8, 2024 · 2 comments
Open

bug in write_results #231

floswald opened this issue Feb 8, 2024 · 2 comments

Comments

@floswald
Copy link
Contributor

floswald commented Feb 8, 2024

julia> using BlackBoxOptim

julia> function rosenbrock2d(x)
         return (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
       end
rosenbrock2d (generic function with 1 method)

julia> res = bboptimize(rosenbrock2d; SearchRange = (-5.0, 5.0), NumDimensions = 2, SaveFitnessTraceToCsv = true, SaveParameters = true)
Starting optimization with optimizer DiffEvoOpt{FitPopulation{Float64}, RadiusLimitedSelector, BlackBoxOptim.AdaptiveDiffEvoRandBin{3}, RandomBound{ContinuousRectSearchSpace}}
0.00 secs, 0 evals, 0 steps

Optimization stopped after 10001 steps and 0.06 seconds
Termination reason: Max number of steps (10000) reached
Steps per second = 174100.43
Function evals per second = 176050.16
Improvements/step = 0.20260
Total function evaluations = 10113


Best candidate found: [1.0, 1.0]

Fitness: 0.000000000

ERROR: MethodError: no method matching replace(::String, ::Regex, ::String)

Closest candidates are:
  replace(::AbstractString, ::Pair...; count)
   @ Base strings/util.jl:847
  replace(::Union{Function, Type}, ::Any; count)
   @ Base set.jl:739
  replace(::Any, ::Pair...; count)
   @ Base set.jl:686

Stacktrace:
 [1] write_result(ctrl::BlackBoxOptim.OptRunController{DiffEvoOpt{…}, BlackBoxOptim.ProblemEvaluator{…}}, filename::String)
   @ BlackBoxOptim ~/.julia/dev/BlackBoxOptim/src/opt_controller.jl:376
 [2] write_result(ctrl::BlackBoxOptim.OptRunController{DiffEvoOpt{…}, BlackBoxOptim.ProblemEvaluator{…}})
   @ BlackBoxOptim ~/.julia/dev/BlackBoxOptim/src/opt_controller.jl:373
 [3] run!(oc::BlackBoxOptim.OptController{DiffEvoOpt{…}, FunctionBasedProblem{…}})
   @ BlackBoxOptim ~/.julia/dev/BlackBoxOptim/src/opt_controller.jl:477
 [4] bboptimize(functionOrProblem::Function, parameters::Dict{…}; kwargs::@Kwargs{…})
   @ BlackBoxOptim ~/.julia/dev/BlackBoxOptim/src/bboptimize.jl:93
 [5] bboptimize
   @ BlackBoxOptim ~/.julia/dev/BlackBoxOptim/src/bboptimize.jl:91 [inlined]
 [6] top-level scope
   @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.
@floswald
Copy link
Contributor Author

floswald commented Feb 8, 2024

also there are a bunch of strftime calls which need to be updated to Libc.strftime

@hoasxyz
Copy link

hoasxyz commented Mar 20, 2024

Unfortunately, I used the same code as you @floswald but encountered an error. Could you please tell me where the problem might be?

julia> using BlackBoxOptim
       function rosenbrock2d(x)
           return (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
       end

       res = bboptimize(rosenbrock2d; SearchRange = (-5.0, 5.0), NumDimensions = 2, SaveFitnessTraceToCsv = true, SaveParameters = true, TraceMode = :verbose)
Starting optimization with optimizer DiffEvoOpt{FitPopulation{Float64}, RadiusLimitedSelector, BlackBoxOptim.AdaptiveDiffEvoRandBin{3}, RandomBound{ContinuousRectSearchSpace}}
0.00 secs, 0 evals, 0 steps
DE modify state:

Optimization stopped after 10001 steps and 0.09 seconds
Termination reason: Max number of steps (10000) reached
Steps per second = 107537.71
Function evals per second = 108752.76
Improvements/step = 0.19530
Total function evaluations = 10114   


Best candidate found: [1.0, 1.0]

Fitness: 0.000000000

ERROR: SystemError: opening file "240320_202158_<unknown>_2d_DiffEvoOpt{FitPopulation{Float64},_RadiusLimitedSelector,_BlackBoxOptim.AdaptiveDiffEvoRandBin{3},_RandomBound{ContinuousRectSearchSpace}}.csv": Invalid argument
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base .\error.jl:176
  [2] systemerror
    @ .\error.jl:175 [inlined]
  [3] open(fname::String; lock::Bool, read::Bool, write::Nothing, create::Nothing, truncate::Nothing, append::Bool)
    @ Base .\iostream.jl:293
  [4] open
    @ .\iostream.jl:275 [inlined]
  [5] open(fname::String, mode::String; lock::Bool)
    @ Base .\iostream.jl:356
  [6] open
    @ .\iostream.jl:355 [inlined]
  [7] save_fitness_history_to_csv_file(a::TopListArchive{…}, filename::String; header_prefix::String, line_prefix::String, include_header::Bool, bestfitness::Nothing)
    @ BlackBoxOptim E:\.julia\packages\BlackBoxOptim\lZtsr\src\archive.jl:182
  [8] save_fitness_history_to_csv_file
    @ E:\.julia\packages\BlackBoxOptim\lZtsr\src\archive.jl:178 [inlined]
  [9] write_result(ctrl::BlackBoxOptim.OptRunController{DiffEvoOpt{…}, BlackBoxOptim.ProblemEvaluator{…}}, filename::String)
    @ BlackBoxOptim E:\.julia\packages\BlackBoxOptim\lZtsr\src\opt_controller.jl:378
 [10] write_result(ctrl::BlackBoxOptim.OptRunController{DiffEvoOpt{…}, BlackBoxOptim.ProblemEvaluator{…}})
    @ BlackBoxOptim E:\.julia\packages\BlackBoxOptim\lZtsr\src\opt_controller.jl:373
 [11] run!(oc::BlackBoxOptim.OptController{DiffEvoOpt{…}, FunctionBasedProblem{…}})
    @ BlackBoxOptim E:\.julia\packages\BlackBoxOptim\lZtsr\src\opt_controller.jl:476
 [12] bboptimize(functionOrProblem::Function, parameters::Dict{…}; kwargs::@Kwargs{…})
    @ BlackBoxOptim E:\.julia\packages\BlackBoxOptim\lZtsr\src\bboptimize.jl:93
 [13] bboptimize
    @ E:\.julia\packages\BlackBoxOptim\lZtsr\src\bboptimize.jl:91 [inlined]
 [14] top-level scope
    @ e:\1WHU\item\jsj\julia_project\test.jl:397
Some type information was truncated. Use `show(err)` to see complete types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants