Replies: 6 comments 2 replies
-
I believe it is a good idea. I often print the model to see variables / constraints and I believe a recap saying how many variables and how many constraints/propagators of each kind are present in the model may be useful. Perhaps a method indicating how many are instantiated / entailed (or passive) would be useful too (this could be called before solving, after initial propagation, in the middle of the search, on solution using incomplete search...) Printing the constraint network is also a nice feature. I think it is already a very good start! |
Beta Was this translation helpful? Give feedback.
-
You are right @cprudhom, let's continue the discussion here. I guess that deplacing the code into a new class, something like ModelAnalysis for example, makes totally sense, especially if we add new analysis functionnalities. Currently, the existing code allows easily to list all types of variables, and for each type list instantiated, constants and unconstrained ones. I also found interesting to list variables by domain size, as it might give some precisou insights. As suggested by @jgFages, I made the code such that it can be called at any moment. About exports, I think that JSON, with appropriate data structures, is the best format (most especially compared to CSV for example) as it allows for easy data manipulation otherwise. Does anyone have a structure in mind ? For now, I can think of listing all variables with their propagators, all propagators/constraints with their variables, and some properties (instantiated, reified, etc.) for each. What functionalities should we add ? I have the following in mind for now:
|
Beta Was this translation helpful? Give feedback.
-
The propagator arity is a good idea for n-ary constraints. Another approach would be to gather them by ranges (1, 2, 3, 4-100, 101-1000, >1000). It would be less accurate but more concise (if we have hundreds of sums with minor arity differences the exact arity approach may become hard to read - which can happen as constants are removed from the sums as preprocessing). Regarding the format I am not so sure the method should return JSON. Whatever the format, remains the question of the structure. For instance we could have a flat list of <propagator, arity, quantity> Regarding the graph, I think it should be done in a separate function returning graphviz format (dot format). |
Beta Was this translation helpful? Give feedback.
-
I guess that we could indeed gather variables' domain size by ranges instead of raw value. That would probably ease the readiness of the printing. I guess we could have both: the default version would be to gather them by ranges, and another one would gather them by raw values, allowing the user for different levels of details. Similarly, I would suggest to have different versions between the pretty printing and the JSON export. For the pretty printing, I think of something like in PR #939, maybe with some refactoring or adding in case of needs. Yes, I was thinking of the graphviz format too. We might also think of given ready-to-use functions for analysing the graph. And, yes, of course, the weighted function would come later as we don't know for now how to do it usefully. |
Beta Was this translation helpful? Give feedback.
-
That sounds great. Note that the Graphviz/Gephi convertos already exist (see Graphviz and Gephi). Also, adding some higher level other informations (like how many constraints were transformed while posted) may require to add some counters in the code. In that case, I think a |
Beta Was this translation helpful? Give feedback.
-
I still need to work on the graph we talked about, but everything else is available in ModelAnalysis class, which you can look at in PR #939. To have an idea of the printing and JSON export, I invite you to add the following lines in the MarioKart example (most especially in the MarioKart.buildModel() function) and to run it: ModelAnalyser modelAnalyser = model.getModelAnalyser();
modelAnalyser.analyse();
modelAnalyser.printAnalysis();
modelAnalyser.toJson("path/to/marioKartAnalysis.json"); |
Beta Was this translation helpful? Give feedback.
-
Currently, when one models a problem, it is possible to print various statistics about the model.
In some specific cases, that is when
warn user
option is on, some warnings can also be printed to the console (like unposted constraints for instance).I believe it would be more convenient to define an
analyse
method in theModel
API to get all these insights, and may be more.For instance, I imagine the following values:
There are certainly other insights that can be considered (constraint network density, ...).
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions