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

Change Model::setStateIsNonNegative logic #1648

Merged
merged 2 commits into from
Feb 1, 2022
Merged

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Feb 1, 2022

Previously model.setStateIsNonNegative(model.getStateIsNonNegative())
failed if conservation laws were enabled. That feels unintuitive.
Now it works.

Previously `model.setStateIsNonNegative(model.getStateIsNonNegative())`
failed if conservation laws were enabled. That feels unintuitive.
Now it works.
@codecov
Copy link

codecov bot commented Feb 1, 2022

Codecov Report

Merging #1648 (f81412d) into develop (e92cad4) will increase coverage by 0.05%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1648      +/-   ##
===========================================
+ Coverage    78.81%   78.87%   +0.05%     
===========================================
  Files           69       69              
  Lines        10717    10717              
===========================================
+ Hits          8447     8453       +6     
+ Misses        2270     2264       -6     
Flag Coverage Δ
cpp 75.42% <0.00%> (+0.08%) ⬆️
petab 66.68% <ø> (ø)
python 68.23% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/model.cpp 84.44% <0.00%> (ø)
src/spline.cpp 71.57% <0.00%> (+6.31%) ⬆️

src/model.cpp Outdated
@@ -609,7 +609,11 @@ std::vector<bool> const &Model::getStateIsNonNegative() const {
}

void Model::setStateIsNonNegative(std::vector<bool> const &nonNegative) {
if (nx_solver != nx_rdata) {
auto any_state_non_negative = std::any_of(state_is_non_negative_.begin(),
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what's implemented here, shouldn't this be applied to nonNegative? Not implementing this was primarily a result of lazyness. If we specify what kind of indices are passed here (solver or rdata x), we could also support setting non_negative states, just need to map between the two.

Copy link
Member Author

@dweindl dweindl Feb 1, 2022

Choose a reason for hiding this comment

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

True. Thanks.

I'll open a separate issue for that. #1649

Copy link
Member Author

Choose a reason for hiding this comment

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

If we specify what kind of indices are passed here (solver or rdata x), we could also support setting non_negative states, just need to map between the two.

With x_solver indices we wouldn't have to check whether it actually is a solver state. However, I'd guess that most users wouldn't want to care about x_solver at all, and therefore, x_rdata would be more appropriate. Or we just do it ID-based. That's probably the most convenient. What would be your preference?

Copy link
Member

Choose a reason for hiding this comment

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

If we specify what kind of indices are passed here (solver or rdata x), we could also support setting non_negative states, just need to map between the two.

With x_solver indices we wouldn't have to check whether it actually is a solver state. However, I'd guess that most users wouldn't want to care about x_solver at all, and therefore, x_rdata would be more appropriate. Or we just do it ID-based. That's probably the most convenient. What would be your preference?

I agree, I would expect that users want to pass x_rdata. For id based specification we should probably add another function as changing this function would be API breaking.

@sonarcloud
Copy link

sonarcloud bot commented Feb 1, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@dweindl dweindl merged commit f7c005d into develop Feb 1, 2022
@dweindl dweindl deleted the fix_setStateIsNonNegative branch February 1, 2022 22:27
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

Successfully merging this pull request may close these issues.

2 participants