1

我正在使用 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$3(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"
    }
  }
}
4

1 回答 1

2

正确的身体是这样的:

{
  "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"
      }
    ]
  }
}

problem-instance使用 JSON 格式时,您需要使用解决方案的 FQCN(完全限定的类名)而不是作为属性名。

于 2019-09-02T10:35:11.057 回答