optaplannerredhat-brms

Red Hat Decision Manager 7.3 OptaCloud solver example not working


I am using Red Hat Decision Manager 7.3 and and trying to get the OptaCloud sample working, specifically when submitting the problem to the solver, which throws the following error:

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)

This occurs when I pass in the following JSON request body to the /server/containers/{containerId}/solvers/{solverId}/state/solving endpoint:

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

I have tried different variations on the request and get the same error being logged, but I always get a HTTP 200 back from the REST call.

Any ideas as to what the issue might be (either me or a possible bug), or does anyone have a JSON request that does work. As seems to be the theme with RHDM, the documentation is less than clear.

Thanks in advance.

UPDATE

Thank you to yurlocs answer below, this now works. I now get back the following response when I call the /server/containers/{containerId}/solvers/{solverId}/bestsolution endpoint after submitting the request:

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

Solution

  • The correct body looks like this:

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

    You need to use solution's FQCN (fully qualified class name) instead of problem-instance as the property name when using JSON format.