Search code examples
droolsoptaplanner

Using DSL and DSLR in OptaPlanner


I am newbie working on the NQueens example in OptaPlanner. In the nQueensSolverConfig.xml file there is a scoreDrl tag where I can put my DRL file.

Now I am interested in using DSL and DSLR files instead of the DRL file so the rules will look more like natural language.

I tried creating a scoreDsl, dslr and dsl tag in the config file but no luck.

How can this be done?

Many thanks.


Solution

  • <scoreDsl> is not (yet) available, as there's no field for it on ScoreDirectorFactoryConfig.java.

    I believe that if you specify a DSL resource in <scoreDrl> in 6.2, it would actually work (yes, I realize that's semantically incorrect), because it ends up calling this code: kieFileSystem.write(kieResources.newClassPathResource(scoreDrl, "UTF-8")); so any KIE resource would be accepted actually.

    Alternatively, build your own KieBase first and use ScoreDirectorFactoryConfig.setKieBase().