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

Allow additional constraint for FittedBondDiscountCurve #1753

Closed
wants to merge 6 commits into from

Conversation

CayOest
Copy link
Contributor

@CayOest CayOest commented Aug 1, 2023

2nd try:
The Constraint is given by the constructor, not a setter method.

@coveralls
Copy link

coveralls commented Aug 1, 2023

Coverage Status

coverage: 71.923% (+0.02%) from 71.908% when pulling ae8fa66 on CayOest:982_constraint2 into 520d62f on lballabio:master.

@@ -323,6 +329,11 @@ namespace QuantLib {
return optimizationMethod_;
}

inline Constraint
Copy link
Contributor

@sweemer sweemer Aug 2, 2023

Choose a reason for hiding this comment

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

I think it would be better to return const Constraint& to avoid a copy where not needed. Same with the other methods in this class in a future PR (doesn't have to be you).

Copy link
Owner

Choose a reason for hiding this comment

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

Cay, I have to ask—are you going to be a problem for this project? Because whatever someone's contributing is not worth causing other people to leave because they're insulted.

(Also, a word to the wise: even if you delete or edit comments, they are also sent via email to me and whoever commented on the PR.)

Copy link
Contributor

Choose a reason for hiding this comment

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

(Also, a word to the wise: even if you delete or edit comments, they are also sent via email to me and whoever commented on the PR.)

And also to everyone who turned on All Activity in the notifications.

: constrainAtZero_(constrainAtZero), weights_(weights), l2_(std::move(l2)),
calculateWeights_(weights.empty()), optimizationMethod_(std::move(optimizationMethod)),
minCutoffTime_(minCutoffTime), maxCutoffTime_(maxCutoffTime) {}
minCutoffTime_(minCutoffTime), maxCutoffTime_(maxCutoffTime), constraint_(constraint) {}
Copy link
Contributor

@sweemer sweemer Aug 2, 2023

Choose a reason for hiding this comment

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

Suggested change
minCutoffTime_(minCutoffTime), maxCutoffTime_(maxCutoffTime), constraint_(constraint) {}
minCutoffTime_(minCutoffTime), maxCutoffTime_(maxCutoffTime), constraint_(std::move(constraint)) {}

Same thing needs to be done for the other constructors.

@lballabio
Copy link
Owner

That's ok, I can do those quick changes before merging.

- avoid a few copies;
- use initializer lists for readability;
- use delegating constructors to reduce duplication
The constraint should be set to the underlying method instead.
@lballabio lballabio linked an issue Aug 2, 2023 that may be closed by this pull request
@lballabio lballabio changed the title 982 constraint2 Allow additional constraint for FittedBondDiscountCurve Aug 2, 2023
@lballabio
Copy link
Owner

Cay, I don't know what you're going through, but you can do this in a civil way and stop abusing Jonathan, or you can get banned. Gently, of course. Your choice.

This said, you're misunderstanding how copy elision works. Cases such as this are the reason std::move was added to the standard.

@CayOest
Copy link
Contributor Author

CayOest commented Aug 2, 2023 via email

@CayOest
Copy link
Contributor Author

CayOest commented Aug 2, 2023 via email

@lballabio lballabio closed this Aug 2, 2023
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.

FittedBondDiscountCurve: No constraint can be set
5 participants