Comments (5)
I'm going to have to think about this. I'm wanting to setup a test which will validate correct/incorrect behavior. I will setup some tests tomorrow and see if we are getting the intended behavior.
from flips.
If I tweak the expression, maybe it will be easier to tell if this is the correct behavior or not.
Multiply (2.0, AddFloat (2.0, Empty)) + AddFloat (-2.0, Empty)
I negated the last float. Now the actual output from evaluateNode
is [ 4.0; -4.0 ]
, which then sums to 0
. Instead, I expect the output of evaluateNode
to be [ 4.0; -2.0 ]
, which sums to 2
.
Now amplify this by replacing every occurrence of 2
with n
for some large n
. The actual output after summing remains 0
while I expect the the output after summing to be n / 2
.
Should the output after summing be exactly 0
or arbitrarily far away from it?
from flips.
I'm going to have this fixed today and put out a new release
from flips.
It is definitely wrong.
This code:
let d = Decision.createBoolean "d1"
let e = 2.0 * (1.0 * d) + 1.0 * d
let r = LinearExpression.Reduce e
Produces
val r : ReducedLinearExpression =
{ DecisionTypes = dict [(DecisionName "d1", Boolean)]
Coefficients = dict [(DecisionName "d1", 4.0)]
Offset = 0.0 }
But should produce this
val r : ReducedLinearExpression =
{ DecisionTypes = dict [(DecisionName "d1", Boolean)]
Coefficients = dict [(DecisionName "d1", 3.0)]
Offset = 0.0 }
The reason that it is not causing a problem in our current code is that we don't have cases where we are multiplying LinearExpression
in this way.
I believe this is the correct implementation:
| AddLinearExpression (lExpr, rExpr) ->
evaluateNode (multiplier, state) lExpr (fun (_, lState) -> evaluateNode (multiplier, lState) rExpr cont)
The behavior would technically equivalent to what you proposed @TysonMN because the state
is made up of mutable collections.
from flips.
Yep, that implementation also works. I see the test you added in 90f4940. It looks great.
from flips.
Related Issues (20)
- Contract violation of Equals HOT 15
- Correctness of evaluateNode HOT 1
- Summing a list of floating-point numbers HOT 21
- LinearExpression.Evaluate is incorrect HOT 2
- Update Examples to current API HOT 3
- Flips 3.0 design: explore gener(ic)alization space
- Add tests that ensure recursion uses tail calls HOT 4
- Would you be interesting in some background / related links ? HOT 2
- why is #r "nuget: Flips,2.4.4" saying .net framework and not netstandard? HOT 8
- Units of Measure missing overload HOT 1
- Sample code snippet and introduction for the fslab website
- Out of memory only for CBC and GLOP HOT 7
- question - validate decisions dynamically based on values of other decisions HOT 4
- Question - Using objective expression in a constraint HOT 6
- Version 2.4.7 locked to FSharp.Core 5.0.0 HOT 2
- Add up-for-grabs issues HOT 4
- Question - Division or multiplication between decisions in linear expression HOT 6
- Incorrect UoM for float multiplied with LinearExpression
- [docs] Missing `WriteMPSFile` field in settings type of introduction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flips.