Skip to content
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

Add Constraint #26

Closed
adussarps opened this issue May 6, 2019 · 4 comments
Closed

Add Constraint #26

adussarps opened this issue May 6, 2019 · 4 comments

Comments

@adussarps
Copy link

Add an option to constraint linear coefficients to a range of values (e.g >0 ).

@cjekel
Copy link
Owner

cjekel commented May 6, 2019

I could potentially create a constrained fit where each breakpoint is subjected to per-determined constraints. The following code sets up this constraint lower and upper limits, just as an example.

# for two breakpoints; arbitrary example 
# 0.1 <= breakpoint[0] <= 0.15
# 0.5 <= breakpoint[1] <= 0.7
g = np.zeros((2, 2)  # constraints
g[0, 0] = 0.1
g[0, 1] = 0.15
g[1, 0] = 0.5
g[1, 1] = 0.7

Then the optimization would find the best breakpoint subject to g.

Do I understand this correctly?

@cjekel
Copy link
Owner

cjekel commented May 16, 2019

For now this could be done using a custom optimizer like https://jekel.me/piecewise_linear_fit_py/examples.html#use-custom-optimization-routine where you manually specify the bounds.

I'll try to include an optional bounds parameter in the fitting routines for this case.

@cjekel
Copy link
Owner

cjekel commented Jun 15, 2019

@adussarps I'm not sure if I understand your request to constrain linear coefficients, but I added an option to constrain the search space for breakpoints. Does this example solver your issue? or are you looking to add constraints for each slope (and the change from the previous slope)?

@adussarps
Copy link
Author

Yes it's fine thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants