Search code examples
optaplanneroptapy

How to activate FAST_ASSERT mode in Optapy


First, thanks to work on a Python version of OptaPlanner. I thinks it's a great idea. I have encountered a problem. I have a SolverConfig objectif in Optapy and I want to activate the FAST_ASSERT mode without passing by the XML file but I can't find a way. Does anyone know how to achieve that ?


Solution

  • Like OptaPlanner, you can configure all of OptaPy programmatically. All configuration classes can be found in the optapy.config module (which shares the same structure as the org.optaplanner.core.config Java package). As for your particular question, this is how you can configure the enviroment mode programmatically in OptaPy:

    import optapy.config
    
    solver_config = optapy.config.solver.SolverConfig() \
        .withEnvironmentMode(optapy.config.solver.EnvironmentMode.FAST_ASSERT) \
        .withSolutionClass(Solution) \
        .withEntityClasses(Entity) \
        .withConstraintProviderClass(my_constraints)