-
Notifications
You must be signed in to change notification settings - Fork 93
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
Dev query logger #61
Dev query logger #61
Conversation
clazarus
commented
Jun 1, 2018
- added InputQuery.saveQuery(filename) which serializes a query to a file
- PiecewiseLinearConstraint:
- Added pure virtual serializeToString() - requiring a serialize function for each type of plc
- Added pure virtual PiecewiseLinearConstraint(string) - requiring a constructor that can deserialize
- ReluConstraint:
- implemented the corresponding functions
- MaxConstraint:
- implemented the corresponding functions
- QueryLoader: Object that parses a serialized queries and produced an InputQuery
- accompanied by a mock main to showcase usage
- correct functionality has been verified by confirming idempotency of serialized queries (ie. serializing and query, loading it serializing it again results in same serialization)
- TODO: In implementing this functionality we discovered that there is some unexplainable behavior with queries that are missing bounds on some variables. Preprocessing steps would appear to be responsible but InputQueries were inspected before preprocessing and so missing variable bounds should cause no issues.
- thanks to @kjulian3 for providing initial query serializer.
- adding Kyle's printQuery()
- constraint serializers added
- relu serializer implemented - max serializer implemented
- logger complete - missing parser logic
- WIP: file parser
- todo: max parser - issues with preprocessing
- deal with missing bounds - clean up
Hi Chris, |
- Mock serializeToString() - Mock serial constructor
Oh sorry, I hadn't noticed. I've added the corresponding functions to the MockConstraint. |
TODO: add unit tests
have pure virtual constructors)
I did some editing and left a few comments, please have a look |
… saveQuery() to use File.h instead of ofstream.
Hi Guy, thank you for your comments. I have addressed all of them except for replacing ofstream with File.h I think doing this will require reimplementing most of the logic in loadQuery(), I am happy to do it if you consider it necessary. I was following the pattern from the original AcasNNet parser, is this incorrect? |
Hi Chris, |
src/engine/InputQuery.h
Outdated
/* | ||
Serializes the query to a file which can then be loaded using QueryLoader. | ||
*/ | ||
void saveQuery( const std::string &fileName ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use our String class instead of std::string
src/engine/ReluConstraint.cpp
Outdated
starts with "relu,". | ||
What do you think? | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment still needs addressing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed this issue.
|
||
TS_ASSERT_EQUALS( file->lastPath, "query.dump" ); | ||
|
||
delete inputQuery; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also still needs addressing
#include "ReluConstraint.h" | ||
|
||
// TODO: add a unit test for a sanity check | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another TODO
List<String> tokens = line.tokenize( "," ); | ||
|
||
// Todo: check something about the number of tokens | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
equation.addAddend( coeff, varNo ); | ||
} | ||
inputQuery.addEquation( equation ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line
src/query_loader/QueryLoader.cpp
Outdated
} | ||
serializeConstraint = serializeConstraint.substring(0, serializeConstraint.length()-1); | ||
//++it; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment and empty line
src/query_loader/QueryLoader.cpp
Outdated
} | ||
else | ||
{ | ||
// Todo: Unsupport constraint, add error handling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
src/query_loader/QueryLoader.cpp
Outdated
|
||
|
||
PiecewiseLinearConstraint *constraint = NULL; | ||
printf("Constraint: %u, Type: %s \n", i, coType.ascii()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log()
{ | ||
// Todo: Unsupport constraint, add error handling | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi Parth, Shantanu, Things look mostly in good shape. A few additional comments: Finally, there's the very important matter of unit tests: I haven't reverted the already-merged pull request, but please address these comments in the near future. If anything is unclear or if you need my help, don't hesitate to ask. I'll look at the MaxConstraint pull request next. |
* query logger * Relu deserializer * max constraint deserializer * adding functions for tests * Mock serializeToString() * Mock serial constructor * loadQuery() and saveQuery() to use File.h instead of ofstream. * mock infrastructure for testing classes that use File * Adding saveQuery function interface in python * Updating make file