# Optimization of parameter in Matlab ?

27 views (last 30 days)
George Ghimire on 5 Oct 2020
Edited: Mario Malic on 6 Oct 2020
Hi I have 10 parameter to optimize. These are material parameter which define the material properties. When the material is simulated in Ansys with initial 10 parameter value I get Admittance curve. I already have my experimental Admittance curve. Now i have to find the set of 10 parameter that will make my Simulated and experimental curve same. How can i do this?
George Ghimire on 6 Oct 2020
Hi @Mario after simulation i already will have the simulated results in a folder. Now whats the next procedure

George Ghimire on 6 Oct 2020
The mathematical form cannot be expressed exactly for optimization. I am looking for solution on Matlab . Consider I have simulated curve or value which is related to my 10 initail parameter ( but there is no mathematical equation). Also i have my experimental curve. Now i want to fit my simulated curve to experimental curve. By this way simulated curve changes and it should give new 10 value. This new value will be my optimised value
Alan Stevens on 6 Oct 2020
Your simulated curve is, presumably, constructed using your 10 parameters. Is that not a mathematical form?

Mario Malic on 6 Oct 2020
Edited: Mario Malic on 6 Oct 2020
Well, first of all, you need to set up connection with ANSYS through actxserver, or play with input/output files and scripting the simulation procedure.
See question and answer here to get an idea how to set up the optimisation procedure, it's different software but principle is the same. To solve the problem this way is difficult, especially if simulating the model takes long or if you're looking for global minima.
Choosing the optimisation solver, algorithms, optimisation options depends on your objective function, which is minimising the difference between these curves.
Good luck.
Mario Malic on 6 Oct 2020
Edited: Mario Malic on 6 Oct 2020
problem.objective = @(x)Obj_Function(x)
%along with the rest of the inputs for the problem structure
[x, fval] = fmincon(problem)
How do you explicitly say what's your objective to MATLAB, or what is its value?
function f_obj = Obj_Function(x)
% Prepare an input file (text) of simulation, find where are these parameters that you're trying to optimise
% Write a function that reads input file, modifies the parameters and returns the modified input file
% Run the modified file in batch mode
% Once the simulation is finished, you have to postprocess the results. If you're able to automatically generate results in text file through an input file, that's great, otherwise, you have to look for a way to do it
% Read text file with results and compare it with experimental curve, you have to determine some sort of measure to describe the differences between curves. For simplicity, this measure can be a scalar value, a single number.
% Return this measure as a value for objective function
fobj = calculate_obj_value;
end
If you check the link I wrote in previous reply, in that example, objective was to minimise sum of energies, so in that case
fobj = MyK1_Energy + MyK2_Energy
For your case, it's a bit more difficult, since you minimise difference of two curves, and that is up to you to define a measure. Should it be sum of differences at measured points, sum of least squares or something else.
Edit: It doesn't have to be fmincon, you can choose what's appropriate for your problem.

### Categories

Find more on Solver Outputs and Iterative Display in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by