Note that this is just an illustrative example of a problem I'm experiencing with a more complicated ODE, that is, even with the complicated ODE, having a sinusoidal input the optimal value is found relatively quickly.įirst let's generate the white noise input and save it into an. When using a sinusoidal input, fmincon finds the optimal value relatively quickly. The issue I am having is that fmincon takes a very long time to find the optimal value when using a white noise input. The cost function is taken to be absolute maximum displacement of the mass, that is, $\max_\limits(|x(t)|)$. Where $f(t)$ is taken to be constant amplitude white noise. Again, I don't know enough about your problem, but it's just a possibility.I am trying to use Matlab's fmincon function to find the optimal value of $k$ for the following ODE, which represents a mass-spring system, Given that you have 11 design variables, that's a big task to determine which are definitely contributing to the objective function evaluation and being optimized. This might be more difficult to determine, but it's possible that some of your design variables might not affect the evaluation of the objective function when coupled with other design variables. GlobalSearch is fairly easy to implement, it basically creates multiple start points for your fmincon and attempts to converge on a global minimum and eliminate local convergence. I'm not sure if you're a professional or a student, but if you're at a university, you can surely get access to the optimization toolbox. (c) Use the GlobalSearch function in the optimization toolbox. This could be as simple as changing to SQP, interior point, etc. You could rectify this a few ways: (a) New initial guesses (b) Use a different solver. You may already have a good grasp on fmincon, but it is a gradient based solver, and you could have coincidentally placed some of your initial guesses at local minima. Feel free to ask more questions if you need some help with that. 'nonlcon'), formulate the constraints in the required way, and then call the function after fmincon while leaving the bounds as an empty set. If you look in tutorials, you'll basically create another function (e.g. I honestly can't tell you why it would be better, but it's how I learned to use fmincon, and it's worked better for me in the past when I've compared the two methods. I typically use a nonlinear constraints function for the bounds. However, a few things that I would look into, given my somewhat limited knowledge of fmincon: It's a little hard to guess what's wrong here without knowing everything about the problem, objective function, constraints, etc. Since the difference between both functions is the constraints, I assume that is the problem but as you can see they look fine.Īny ideas? Also as a note, it may be coincidence, but the parameters that are almost not changed are the ones that are "big" in comparaison to the small ones (130 for example doesn't change while 300e-9 does). What also bugs my mind if that some parameters are changed while others almost remain the same in the initial phase of the algorithm (when it's just checking what each parameter does creating small disturbances in those). Upper bound: Īs you can see it should work pretty well. The values for those are: Initial guess: The value of handles.p0 is the initial guess. I call fmincon as: p = handles.pmin and handles.pmax are the lower and upper bound respectively. My lower bound is always lower than the initial parameter value and my upper higher. What's wrong? I can only think it's the constraints but I have checked it several times. So the question is, is this normal? Why some parameters are barely changed? It's the initial iteration, the algorithm needs to get an idea of the system so it should change them all, not some. As far as I know all the constraints are well placed simply with the ub,lb parameter in fmincon. I have 11 parameters to optimize and some are varied 5% initially and others nothing at all only when using fmincon (fminsearch is always fine). As far as I know I'm setting everything alright and I don't know why this is happening. Then it says it has found the solution for the tolerance and constraints given. When I set constraints with fmincon this value is changed to something like 0.20000001 maybe. If I use fminsearch (which doesn't use constraints) if I have a parameter with an initial value of 0.2 and I track every step in the program as I plot every change from the objective function called from fmincon I can see the parameter is changed initially to 0.19 or something of the like when using fminsearch (10% change). The problem comes when I add constraints. I have an objective function where I run a simulation in another program and compare results to create an error. Hi, I have a problem to minimize and I'm trying to use fmincon.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |