Git Product home page Git Product logo

Comments (10)

StefanPofahl avatar StefanPofahl commented on September 24, 2024

Today I have tested the new version of the master-repository and compared the fit result with the one optimized with the Gamry SW:
The script can be found on my fork of this project:
https://github.com/StefanPofahl/EquivalentCircuits.jl/blob/0f77c59ab71c04d2600db160766fbd4cbe237e2e/examples/comparison_EC_Gamry_Fit_against_GenricAlgorithm_Fit.jl

from equivalentcircuits.jl.

MaximeVH avatar MaximeVH commented on September 24, 2024

I have written a script that evaluates a number of optimisation methods for this specific complex equivalent circuit setting.

The script can be found at:
https://github.com/MaximeVH/EquivalentCircuits.jl/blob/master/examples/EC_optimisation_experiment.jl

from equivalentcircuits.jl.

MaximeVH avatar MaximeVH commented on September 24, 2024

selected_methods_nyquists_
selected_methods_error_plot

from equivalentcircuits.jl.

StefanPofahl avatar StefanPofahl commented on September 24, 2024

Hi Maxime! - Thanks for your nice script!
To enable functionality in my Julia-environment I have reworked your example, see here:
EC_optimisation_experiment_Maxime.jl
I have added two optional parameters to the function trace_quality() to enable a weighting of the impedance points.
Do you think, that this makes sense? Is it possible to pass a weighing vector also to the optimization function: optimize()?

And I have added the feature to select only a part of the measured impedance points for optimization.

Another more general question:
Is there also an optimization solver available that uses genetic or evolutionary algorithms for a local stochastic optimization strategy?

from equivalentcircuits.jl.

MaximeVH avatar MaximeVH commented on September 24, 2024

Hi Stefan,

I think weighing the impedance points makes sense in cases where some areas within the impedance spectrum's frequency range are of greater importance than others. If the low frequencies are less important for the circuit you are fitting, it makes sense to allocate a lower weight to them in the fitting quality evaluation and during the optimization of the parameters.

If you want to add weights at certain frequencies during optimisation as well, you can do this by adjusting the objective function in the ObjectiveFunction.jl source file.
The current objective function is implemented as

function objectivefunction(circuitfunc,measurements,frequencies) 
    function objective(x)
        model_output = [circuitfunc(x,fr) for fr in frequencies] 
        return  mean((abs.(measurements - model_output).^2)./(abs.(measurements).^2 .+ abs.(model_output).^2))
    end
    return objective
end

Weights can be included in this function as follows:

function objectivefunction_weighted(circuitfunc,measurements,frequencies,weights) 
    function objective(x)
        model_output = [circuitfunc(x,fr) for fr in frequencies] 
        return  mean(weights .* (abs.(measurements - model_output).^2)./(abs.(measurements).^2 .+ abs.(model_output).^2))
    end
    return objective
end

Here the weights input is a vector of the same dimension as the frequencies input,
where each value is a measure of how much importance is attached to the impedance point at the corresponding frequency. Note that you will also have to adjust the parameter optimisation function such that the modified objective function is used and the weights are included as input.

As for your last question, I have not used such modules before, maybe the Evolutionary.jl package will have what you're looking for.

Regards,
Maxime

from equivalentcircuits.jl.

StefanPofahl avatar StefanPofahl commented on September 24, 2024

Maxime, thanks for the quick replay! I would not change the name of the function, but would specify the weighing factor as optional, what do you think?

from equivalentcircuits.jl.

MaximeVH avatar MaximeVH commented on September 24, 2024

That's fine by me, I can include the relevant optional arguments to the objectivefunction and parameteroptimisation functions, along with the other updates.

from equivalentcircuits.jl.

StefanPofahl avatar StefanPofahl commented on September 24, 2024

That sounds promising :-)
P.S.:
I definitely will have a look on the Evolutionary.jl-package!

from equivalentcircuits.jl.

StefanPofahl avatar StefanPofahl commented on September 24, 2024

The weighting works perfect, please have a look:
https://github.com/StefanPofahl/EquivalentCircuits.jl/blob/9091feb7aa118289137bcaaa88fdf40a59716607/examples/EC_optimisation_experiment_Maxime.jl

from equivalentcircuits.jl.

StefanPofahl avatar StefanPofahl commented on September 24, 2024

Info:

  • The BlackBox Optimization does not work for me on Julia v1.8.3
  • EvolutionStrategy might be a bad option (what I have seen so far)
  • I have not yet tested GeneticAlgorithms

from equivalentcircuits.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.