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

Constraints for multiple intervals #1829

Closed
wants to merge 3 commits into from

Conversation

Qazalbash
Copy link
Contributor

I have implemented three different constraints that involve multiple closed intervals.

  • Union of intervals

$$ x \in \bigcup_{i=1}^{n} [a_i, b_i] \implies \bigvee_{i=1}^{n} (x \in [a_i, b_i]) $$

  • Intersection of intervals

$$ x \in \bigcap_{i=1}^{n} [a_i, b_i] \implies \bigwedge_{i=1}^{n} (x \in [a_i, b_i]) $$

  • Unique intervals. The idea is we have $n$ different parameters and each has its unique constraining intervals.

$$ \bigwedge_{i=1}^{n} (x_i \in [a_i, b_i]) $$

@fehiepsi
Copy link
Member

Hi @Qazalbash, do you have any concrete example of those constraints?

forward_shape=constraint.lower_bounds.shape,
inverse_shape=(constraint.lower_bounds.size,),
),
ExpTransform(),
Copy link
Member

@fehiepsi fehiepsi Jul 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this composed transform is bijective. Could you clarify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this code snippet to test the constraints of the system. This was the best example I could come up with based on a quick review of the test cases. Please note that this code is not based on any specific logic, so feel free to correct me if I'm wrong or suggest improvements!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Probably the tests pass because the domain is quite loose. Exp transform has positive codomain, not union of intervals.

@Qazalbash
Copy link
Contributor Author

For the union of intervals, an example. I now realize we can avoid the intersection of intervals to a single interval. For the unique interval case, I was writing transformation defined as,

$$ f:(x,y)\to (x',y') $$

where, $0 < y \leq x$ and,

$$ x'=\frac{(xy)^{3/5}}{(x+y)^{1/5}},\qquad y'=\frac{xy}{(x+y)^{2}} $$

and turns out the bounds for each are,

$$ 0 < x'<\infty \qquad 0 < y' \leq \frac{1}{4} $$

I had to deal with a similar situation where each element in the event_dim=1 represents a quantity and has its bounds and I had to write a separate constraint for them.

@fehiepsi
Copy link
Member

For the unique interval case, you can use independent(interval(lower_bound, upper_bound)). You are right that the intersection case is just another interval. The trickiest one is the union of intervals, which I think you can assume they do not overlap and maps interval i to (i/n,i/n+1/n) where n is the number of intervals. I guess it is better to avoid dealing with such complicated constraint.

@Qazalbash
Copy link
Contributor Author

I got your point. I still don't get independent(interval(lower_bound, upper_bound)). Can you explain it using my mentioned use case? After that, I will close the PR!

@fehiepsi
Copy link
Member

In that example, I guess you can use the constraint

constraints.independent(constraints.interval(np.zeros(2), np.array([1e6, 0.25])))

@Qazalbash
Copy link
Contributor Author

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants