-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force minimum length of segments to be greater than x #66
Comments
I think there are two ways to approach this.
It's fairly straight forward to just add a constraint function and use a constrained optimization algorithm (option 2). If this doesn't work for you, you may want to investigate a penalty formulation. This jupyter notebook uses SLSQP to apply a constraint function to force a minimum line segment length. You'll need to supply a starting point (or guess) to start the optimization. If you don't know what is a good starting point, check out how I use Latin Hypercube random sampling to run multiple optimizations in the A constraint function could look like: def my_con(var):
var = np.sort(var)
distances = np.zeros(number_of_line_segments)
distances[0] = var[0] - my_pwlf.break_0
distances[-1] = my_pwlf.break_n - var[-1]
for i in range(number_of_line_segments - 2):
distances[i+1] = var[i+1] - var[i]
# element must be greater or equal to 0.0
# in a successfully optimized problem
return np.array((distances.min() - min_length)) This is a single constraint for the minimum length of all segments. It's possible that the return np.array((distances.min() - min_length)) to return distances - min_length [1] Haftka, R. T. and Starnes, J. H., Jr., "Applications of a Quadratic Extended Interior Penalty Functions for Structural Optimization," AIAA Journal, Vol. 14, pp. 718-724, 1976 PDF |
thank you for the very detailed answer -- i'll go through your suggestion asap |
Hello,
How can I add a constraint in the outer optimization function: minimum length of each segment should be >= x?
The text was updated successfully, but these errors were encountered: