Using fminunc with blackbox
9 ビュー (過去 30 日間)
A blackbox code (obj_b3.p) defines a function that takes a vector of length 2 and returns some value based on that function. I want to find the global minimizer, and instead of guess and check I want to use fminunc (have never used before, have looked at doc and help and tried googling examples but they all have known functions that they make anonymous). To do this I intend on using a lot of x0 (guess) values.
how do i set up the basic code?
what I've tried:
v = [1;1] % creates a vector of length 2 (blackbox code won't accept a 1,2, only a 2,1)
x0=[0;0]; % Initial guess for fminunc
v = fminunc(obj_b3,x0)
matlab returns that there aren't enough inputs.
Can someone post a simple example of how to do this using a blackbox.m file (hope its obvious that the blackbox.p file does not allow one to actually see the code to evaluate).
Alan Weiss 2016 年 3 月 23 日
fun = @obj_b3;
x0 = [0;0];
x = fminunc(fun,x0)
You might want to consult the documentation on optimizing a simulation or ODE in case your black-box function does not distinguish between nearby values very well.
MATLAB mathematical toolbox documentation
その他の回答 (1 件)
sanya gode 2019 年 10 月 29 日
I am working on Equivalent Circuit Modeling for estimating the battery parametrs. I read in MAthworks documentation that the model can be Blackboxed for sharing with certain customers so that they can modeify it accourding o the application for which they are using the battery without knowing the internal parameters. I read that once the model is created we need to generate the code and than we have create a new simulink model based on the generated code.
Can you please elaborate on how exactly do we need to blackbox the model based on the generated code ?
Your answers will be very helpful and appreciated.
Thanks in advance.