Constraining to specific values during an optimisation

13 views (last 30 days)
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

Answers (2)

Torsten
Torsten on 19 Jan 2016
  1 Comment
arminass
arminass on 19 Jan 2016
Edited: arminass on 19 Jan 2016
Hi Torsten,
I'm not quite sure if this is what I'm looking for. The system I'm trying to solve is a very nonlinear problem which requires the global optimisation toolbox to find its optimal solution.
In addition, what if I wanted to constrain my solutions so that for example, the angles it finds must be in values of 2 degree increments? At that point, i'm constraining my system so that the angles must have a remainder of zero when divided by 2.
Thank you

Sign in to comment.


Alan Weiss
Alan Weiss on 19 Jan 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 Comments
arminass
arminass on 19 Jan 2016
Edited: arminass on 19 Jan 2016
I seem to have not conveyed what I'm asking properly. I'll update the question.
My optimisation uses independent variables which are physical quantities.
For example, if the independent variable was the angle of a gyroscope, and I knew that gyroscope could take four values, i.e.
theta ∈ {12.2, 40, 50, 78.6666666666}
I could make the lowerBound 12.2 and the upperbound 78.6666 but that would not be a solution to this problem.
Is there a way, to constrain the optimizer so that theta MUST be a value in this set? The values need not necessarily be integer.
I've found a way but I'm not sure if it's necessarily the ideal solution as it makes my code slower.
I've written a constraint as follows:
function [c, ceq] = constraint(x)
c = []
q = 2.5 %quantice the angles to 2.5 degree increments
ceq = mod(x,q)
So this code constrains my optimizer to have the modulus of my angle and my "resolution" be zero.
This sort-of works as my angles are very close to (in this example), increments of 2.5 degrees. However, one of the other reasons I wanted to do this was to reduce the dimensionality of my problem. If I reduce the possible values the optimizer plays with, the optimizer should run faster since the number of possible solutions will sharply decrease. This doesn't seem to be the case however.
Is that a bit clearer?
Thank you for the reply.
Torsten
Torsten on 19 Jan 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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!