-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support negative values in Linear Expressions #41
Comments
In EvalExpr::operator()(AST::UnaryOp v) a Util::MD_NAT value was returned as result, for a potential negative value. The issue was solved by returning a Rational in all possible cases. |
As expressions weren't parsed correctly, a refactor was needed, which included:
|
The following SBG program was evaluated:
producing incoherent results. It was then discovered that the evaluator decided incorrectly the Set implementation to use (OrdSet or UnordSet), as /eval/visitor/check_opt_conds.cpp didn't check the slopes of expressions. This also was corrected. In addition, in the execution of the SCC algorithm it was noted that the subE_map partition wasn't preserved. Debugged. |
A simple program such as:
resulted in:
as both values were parsed as naturals, and the result saved in a Util::NAT struct. This was corrected modifying the evaluator to support this operation, returning a Util::RATIONAL. |
In addition it was decided to use a semicolon to separate assignments and expressions in a SBG program, to avoid ambiguities. Also the use of the "%=" symbol for defining SBGs was changed for a colon, as the previous symbol gave the idea of assignment, which didn't occur while defining a SBG. |
While rewriting all tests to suit the new grammar it was discovered that scc2.test
didn't execute in constant time. This was due to the following condition in the SCC algorithm:
which executed the loop until two vertices in the dmap belonged to the same set-vertex. The example has a recursion 3 -> 4 -> ... -> 30 -> 31 -> 1 where 3 to 31 belong to the same set-vertex. As the subset-edges map was partitioned more than needed, the closest vertices of the recursion (30, 31) were discovered individually. This way, in the next iteration the dmap added both vertices to its domain with distance equal to 0 and ended adding other vertices. This way the not_cycle_edges was an empty set, and in turn ER was also empty. The condition was changed to:
which executes the loop until a recursive vertex that changed its representative is found in dmap. |
The execution of the SBG program:
produced the following result:
which is clearly incorrect, as each vertex is an individual SCC. This was because after handling a recursion, if a recursive rmap was proposed, it wasn't then compared to the original rmap to pick the minimum representative between the two of them. This was corrected with the following code:
|
A simple program such as:
returns the following error:
This prohibits the use of negative numbers in linear expressions, which should be supported.
The text was updated successfully, but these errors were encountered: