Constraining to specific values during an optimisation
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I have some code which uses the PatternSearch function to minimise my system which has a large number of variables.
I currently have upper and lower bounds specified which is great but I'd like to go beyond this and specify sets of specific values with which to constrain my system.
What I want to know is, for example, instead of having the bounds:
0 <= x <= 10
Could I instead have,
x ∈ {0,1,2,3,4,5,6,7,8,9,10} which effectively limits x to be integer.
How would you implement this?
[EDIT2]
I don't necessarily want the constraint to be integer, I want to specify sets with which the independent variables can exist in, in order to reduce my solution space.
Another example:
If I have an angle theta, I know that the possible angles it can take are
theta ∈ {0, 30, 60.5, 89.9995}
How do I force my optimizer to only consider these values for theta?
Or another example
theta ∈ {0,2.5,5,7.5,...,87.5,90}
I've managed to implement a solution for this issue where I've constrained my optimizer by mod(theta,2.5), but this slows my code down when I was hoping, reducing the number of possible values for my independent variables would speed up the optimizer.
[EDIT] I've been thinking about setting the constraint such that
0 = mod(x,1). Is such a constraint possible?
Thank you
0 comentarios
Respuestas (2)
Alan Weiss
el 19 de En. de 2016
It is barely possible that you can use a combination of options to do what you want. I assume that you have no constraints other than bounds, and that you have finite bounds on every component.
- Set the ScaleMesh option to 'off'
- Set the MeshTolerance option to something less than 1 but more than 1/2, such as 0.75
- Use the 'GPSPositiveBasis2N' poll (this is the default PollMethod)
- I also recommend setting CompletePoll to 'on'
- Set all entries in the initial point x0 to integers inside the bounds, AND set finite bounds for every component.
In this case, I believe that all polled points will be integer-valued. I could be wrong about the MeshTolerance setting, perhaps it should be exactly 1, but try it and you'll see.
Alan Weiss
MATLAB mathematical toolbox documentation
2 comentarios
Torsten
el 19 de En. de 2016
For the theta example:
Just use theta = 12.2 in the optimization if the solver returns integer = 1, theta = 40 if integer = 2 and so on and constrain integer <= 4.
Or, if the possible values for theta are not that large, make 4 simulations, one with theta = 12.2, the next with theta = 40 and so on.
Best wishes
Torsten.
Ver también
Categorías
Más información sobre Direct Search en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!