Closed finmod closed 4 years ago
Thanks for noticing this and reporting it. Now updated example for Julia 1.X and it is on latest master:
https://github.com/robertfeldt/BlackBoxOptim.jl/commit/7fbc7f1bdd7b99f4dd6b41f66d9f4fa62159fe7e
Please confirm it works also for you and then I'll close this issue.
Perfect. Thank you. It would be nice to extend this example from a single equation to a system of equations, perhaps as a modl3 section at the end.
Can you expand what you mean by modl3? Or if you have a pointer to a simple example of a system of equations? You mean like a SEM, https://en.wikipedia.org/wiki/Structural_equation_modeling?
I had an example like this in mind: https://github.com/bashtage/linearmodels/blob/master/examples/system_three-stage-ls.ipynb with a view to extend your menu of LS methods from OLS, LAD, Lasso, Ridge to 3SLS and system GMM estimation. But dont' worry to much if it is not obvious to you. The point of using BBO is to substitute matrix inversion and still meet the optimization criteria.
It looks interesting but maybe a bit too specialized to include as an example in BBO. If you go down this route though it would be great if you link to it here and if the code is simple enough then I'd be happy to include it.
In [13] using BlackBoxOptim olsresult = bboptimize(b -> ols_regression_objective(b, x1, y1); SearchRange = (-10.0, 10.0), NumDimensions = 4, MaxSteps = 2e4) @show (best_fitness(olsresult), best_candidate(olsresult))
produces the error:
MethodError: objects of type Array{Float64,2} are not callable Use square brackets [] for indexing an Array.
Stacktrace: [1] mapreduce_first(::Array{Float64,2}, ::Function, ::Int64) at .\reduce.jl:301 [2] mapreduce(::Array{Float64,2}, ::Function, ::Int64) at .\reduce.jl:328 [3] sum(::Array{Float64,2}, ::Int64) at .\reduce.jl:403
[7] fitness(::Array{Float64,1}, ::FunctionBasedProblem{ScalarFitnessScheme{true},ContinuousRectSearchSpace,Nothing}) at C:\Users\Denis\Documents\Finmod\BlackBoxOptim.jl-master\src\problem.jl:61 [8] setup_problem(::Function, ::DictChain{Symbol,Any}) at C:\Users\Denis\Documents\Finmod\BlackBoxOptim.jl-master\src\bboptimize.jl:36 [9] #bbsetup#86(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:SearchRange, :NumDimensions, :MaxSteps),Tuple{Tuple{Float64,Float64},Int64,Float64}}}, ::typeof(bbsetup), ::Function, ::Dict{Symbol,Any}) at C:\Users\Denis\Documents\Finmod\BlackBoxOptim.jl-master\src\bboptimize.jl:87 [10] #bboptimize#85(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:SearchRange, :NumDimensions, :MaxSteps),Tuple{Tuple{Float64,Float64},Int64,Float64}}}, ::typeof(bboptimize), ::Function, ::Dict{Symbol,Any}) at .\none:0 [11] #bboptimize at .\none:0 [inlined] (repeats 2 times)