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

Fix bug in LinearExpression.Evaluate #161

Merged
merged 3 commits into from
Jan 4, 2021

Conversation

TysonMN
Copy link
Contributor

@TysonMN TysonMN commented Jan 3, 2021

Fixes #153

I made two changes in order to keep the tests simple. First, I mades things in the Flips project with internal scope visible to the Flips.Tests project. Second, I weakened an argument type of the internal method LinearExpression.Evaluate.

It is unfortunate that these two new tests are essentially the same as the two tests above them. This is caused by the equivalently duplicate code between LinearExpression.Reduce and LinearExpression.Evaluate. I expect to remove that duplication one day, but not soon.

@@ -216,7 +216,7 @@ and
| AddLinearExpression (lExpr, rExpr) -> getRec (fun l -> getRec cont l rExpr) decisions lExpr
getRec id Set.empty expr

static member internal Evaluate (decisionMap:Map<Decision, float>) (expr:LinearExpression) : float =
static member internal Evaluate (getDecisionCoef: Decision -> float) (expr:LinearExpression) : float =
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious why you went with this type versus the original Map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Map<'a, 'b> is more restrictive than 'a -> 'b. The tests doesn't care what Decisions are in the LinearExpressions. From the perspective of the tests, it suffices for the coefficient corresponding to each Decision to be 1.0.

@matthewcrews matthewcrews merged commit e7e30de into fslaborg:main Jan 4, 2021
@TysonMN TysonMN deleted the fix_bug_153 branch January 4, 2021 16:02
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.

LinearExpression.Evaluate is incorrect
2 participants