Red Hat Decision Manager 7.3 OptaCloud 求解器示例不工作
Red Hat Decision Manager 7.3 OptaCloud solver example not working
我正在使用 Red Hat Decision Manager 7.3 并尝试让 OptaCloud 示例正常工作,特别是在将问题提交给求解器时,它引发了以下错误:
14:51:46,266 ERROR [org.kie.server.services.optaplanner.SolverServiceBase] (pool-10-thread-4) Exception executing solver 'optacloud' from container 'optacloud_1.0.0-SNAPSHOT'. Thread will terminate.: java.lang.IllegalArgumentException: Can not set org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore field optacloud.optacloud.CloudSolution.score to java.util.LinkedHashMap
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)
at java.lang.reflect.Field.get(Field.java:393)
at org.optaplanner.core.impl.domain.common.accessor.ReflectionFieldMemberAccessor.executeGetter(ReflectionFieldMemberAccessor.java:59)
at org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor.getScore(SolutionDescriptor.java:1134)
at org.optaplanner.core.impl.score.director.AbstractScoreDirector.cloneSolution(AbstractScoreDirector.java:213)
at org.optaplanner.core.impl.solver.scope.DefaultSolverScope.setWorkingSolutionFromBestSolution(DefaultSolverScope.java:218)
at org.optaplanner.core.impl.solver.AbstractSolver.solvingStarted(AbstractSolver.java:75)
at org.optaplanner.core.impl.solver.DefaultSolver.solvingStarted(DefaultSolver.java:210)
at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:190)
at org.kie.server.services.optaplanner.SolverServiceBase.lambda$solvePlanningProblem(SolverServiceBase.java:493)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
当我将以下 JSON 请求正文传递到 /server/containers/{containerId}/solvers/{solverId}/state/solving
端点时会发生这种情况:
{
"planning-problem": {
"computerList": [
{
"cpuPower": "10",
"memory": "4",
"networkBandwidth": "100",
"cost": "1000"
},
{
"cpuPower": "20",
"memory": "8",
"networkBandwidth": "100",
"cost": "3000"
}
],
"processList": {
"opta.optacloud.Process": {
"requiredCpuPower": "1",
"requiredMemory": "7",
"requiredNetworkBandwidth": "1"
}
}
}
}
我尝试了不同的请求变体并记录了相同的错误,但我总是从 REST 调用返回 HTTP 200。
关于问题可能是什么的任何想法(我或可能的错误),或者是否有人有 JSON 有效的请求。似乎是 RHDM 的主题,文档不太清楚。
提前致谢。
更新
感谢 yurlocs 在下方的回答,现在可以使用了。我现在在提交请求后调用 /server/containers/{containerId}/solvers/{solverId}/bestsolution
端点时得到以下响应:
{
"container-id": "optacloud_1.0.0-SNAPSHOT",
"solver-id": "optacloud",
"solver-config-file": "optacloud/optacloud/cloudSolverConfig.solver.xml",
"status": "SOLVING",
"score": {
"value": "0hard/-3000soft",
"scoreClass": "org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore"
},
"best-solution": {
"optacloud.optacloud.CloudSolution": {
"computerList": [
{
"cpuPower": 10,
"memory": 4,
"networkBandwidth": 100,
"cost": 1000
},
{
"cpuPower": 20,
"memory": 8,
"networkBandwidth": 100,
"cost": 3000
}
],
"processList": [
{
"requiredCpuPower": 1,
"requiredMemory": 7,
"requiredNetworkBandwidth": 1,
"computer": {
"cpuPower": 20,
"memory": 8,
"networkBandwidth": 100,
"cost": 3000
}
}
],
"score": "0hard/-3000soft"
}
}
}
正确的正文是这样的:
{
"optacloud.optacloud.CloudSolution": {
"computerList": [
{
"cpuPower": "10",
"memory": "4",
"networkBandwidth": "100",
"cost": "1000"
},
{
"cpuPower": "20",
"memory": "8",
"networkBandwidth": "100",
"cost": "3000"
}
],
"processList": [
{
"requiredCpuPower": "1",
"requiredMemory": "7",
"requiredNetworkBandwidth": "1"
}
]
}
}
在使用 JSON 格式时,您需要使用解决方案的 FQCN(完全限定 class 名称)而不是 problem-instance
作为 属性 名称。
我正在使用 Red Hat Decision Manager 7.3 并尝试让 OptaCloud 示例正常工作,特别是在将问题提交给求解器时,它引发了以下错误:
14:51:46,266 ERROR [org.kie.server.services.optaplanner.SolverServiceBase] (pool-10-thread-4) Exception executing solver 'optacloud' from container 'optacloud_1.0.0-SNAPSHOT'. Thread will terminate.: java.lang.IllegalArgumentException: Can not set org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore field optacloud.optacloud.CloudSolution.score to java.util.LinkedHashMap
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)
at java.lang.reflect.Field.get(Field.java:393)
at org.optaplanner.core.impl.domain.common.accessor.ReflectionFieldMemberAccessor.executeGetter(ReflectionFieldMemberAccessor.java:59)
at org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor.getScore(SolutionDescriptor.java:1134)
at org.optaplanner.core.impl.score.director.AbstractScoreDirector.cloneSolution(AbstractScoreDirector.java:213)
at org.optaplanner.core.impl.solver.scope.DefaultSolverScope.setWorkingSolutionFromBestSolution(DefaultSolverScope.java:218)
at org.optaplanner.core.impl.solver.AbstractSolver.solvingStarted(AbstractSolver.java:75)
at org.optaplanner.core.impl.solver.DefaultSolver.solvingStarted(DefaultSolver.java:210)
at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:190)
at org.kie.server.services.optaplanner.SolverServiceBase.lambda$solvePlanningProblem(SolverServiceBase.java:493)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
当我将以下 JSON 请求正文传递到 /server/containers/{containerId}/solvers/{solverId}/state/solving
端点时会发生这种情况:
{
"planning-problem": {
"computerList": [
{
"cpuPower": "10",
"memory": "4",
"networkBandwidth": "100",
"cost": "1000"
},
{
"cpuPower": "20",
"memory": "8",
"networkBandwidth": "100",
"cost": "3000"
}
],
"processList": {
"opta.optacloud.Process": {
"requiredCpuPower": "1",
"requiredMemory": "7",
"requiredNetworkBandwidth": "1"
}
}
}
}
我尝试了不同的请求变体并记录了相同的错误,但我总是从 REST 调用返回 HTTP 200。
关于问题可能是什么的任何想法(我或可能的错误),或者是否有人有 JSON 有效的请求。似乎是 RHDM 的主题,文档不太清楚。
提前致谢。
更新
感谢 yurlocs 在下方的回答,现在可以使用了。我现在在提交请求后调用 /server/containers/{containerId}/solvers/{solverId}/bestsolution
端点时得到以下响应:
{
"container-id": "optacloud_1.0.0-SNAPSHOT",
"solver-id": "optacloud",
"solver-config-file": "optacloud/optacloud/cloudSolverConfig.solver.xml",
"status": "SOLVING",
"score": {
"value": "0hard/-3000soft",
"scoreClass": "org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore"
},
"best-solution": {
"optacloud.optacloud.CloudSolution": {
"computerList": [
{
"cpuPower": 10,
"memory": 4,
"networkBandwidth": 100,
"cost": 1000
},
{
"cpuPower": 20,
"memory": 8,
"networkBandwidth": 100,
"cost": 3000
}
],
"processList": [
{
"requiredCpuPower": 1,
"requiredMemory": 7,
"requiredNetworkBandwidth": 1,
"computer": {
"cpuPower": 20,
"memory": 8,
"networkBandwidth": 100,
"cost": 3000
}
}
],
"score": "0hard/-3000soft"
}
}
}
正确的正文是这样的:
{
"optacloud.optacloud.CloudSolution": {
"computerList": [
{
"cpuPower": "10",
"memory": "4",
"networkBandwidth": "100",
"cost": "1000"
},
{
"cpuPower": "20",
"memory": "8",
"networkBandwidth": "100",
"cost": "3000"
}
],
"processList": [
{
"requiredCpuPower": "1",
"requiredMemory": "7",
"requiredNetworkBandwidth": "1"
}
]
}
}
在使用 JSON 格式时,您需要使用解决方案的 FQCN(完全限定 class 名称)而不是 problem-instance
作为 属性 名称。