typedb / typedb-driver-examples

TypeDB Driver Example Projects and Tutorials
https://typedb.com
Apache License 2.0
84 stars 57 forks source link

Port grakn sudoku-solver example #147

Open krishnangovindraj opened 1 year ago

krishnangovindraj commented 1 year ago

What is the goal of this PR?

Port the grakn sudoku-solver to typeql and add as an example. Distill the schema & queries to the most basic form which also works with the reasoner planner's cost model.

What are the changes implemented in this PR?

typedb-bot commented 1 year ago

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

Code

Architecture

krishnangovindraj commented 1 year ago

Blocked: The sudoku tests will fail till it's run against the improved reasoner planner.

flyingsilverfin commented 1 year ago

Ok so I've had a look over this, questions:

  1. Is it still a interpretable/useful/meaningful sudoku solver if we write the problem statement with permutation generator without a type for row and column etc? I imagine we can introduce row/column passthroughs that generate from permutations if we wanted to?
  2. Do we still need the connector-hack? This isn't a great thing to see in an example...
  3. The architecture isn't quite right. "Driver" isn't a great name. I think you could have an entry point called sudoku_solver.py. You can put the current "Solver" in a typedb_sudoku.py file. The reading of input files etc. should be handled in the solver, and the typedb_sudoku.py should implement the actual communication with TypeDB and solving? What do you think?
krishnangovindraj commented 1 year ago

@flyingsilverfin

Is it still an interpretable/useful/meaningful sudoku solver if we write the problem statement with permutation generator without a type for row and column etc? I imagine we can introduce row/column passthroughs that generate from permutations if we wanted to?

If we use rules, our planner can't tell the difference because of how the AnswerCountEstimator estimates inferred things.

Do we still need the connector-hack? This isn't a great thing to see in an example...

As of now, we do. Without it we don't pick the best plan in the top level. I took a deeper look and we scaled down resolvable-estimates based only on the single most scaling variable, rather than on all of them (Another assumption which seems reasonable for tree structured graphs). That's making the scaling way off. At this point, I'm surprised this worked at all.