Can Constraint Provider and Score Calculator be set and used at same time

49 Views Asked by At

Can ConstraintProvider and ScoreCalculator set and used at same time? Because it's throwing me exceptions...This is the code...

ScoreDirectorFactoryConfig scoreDirectorFactoryConfig = new ScoreDirectorFactoryConfig();
        scoreDirectorFactoryConfig.setConstraintProviderClass(VehicleRoutingConstraintProvider.class);
scoreDirectorFactoryConfig.setInitializingScoreTrend("ONLY_DOWN");
scoreDirectorFactoryConfig.setEasyScoreCalculatorClass(VRPScoreCalculator.class);
solverConfig.setScoreDirectorFactoryConfig(scoreDirectorFactoryConfig);

This is the starting few lines of exceptions...

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vehicleRoutingController': Unsatisfied dependency expressed through field 'vehicleRoutingService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vehicleRoutingService' defined in file [/home/bvasavi/Projects/vehicleroutingproblemvijay/target/classes/com/fleetenable/vrp/api/service/VehicleRoutingService.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.fleetenable.vrp.api.service.VehicleRoutingService]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The scoreDirectorFactory cannot have an easyScoreCalculatorClass and a constraintProviderClass together.
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]

I figured out that the exceptions are because one can't set setConstraintProviderClass and setEasyScoreCalculatorClass together... Can anyone please help me out here!!?

1

There are 1 best solutions below

0
On

There is no way how the two could be used together.