我一直在尝试使用 MPJExpress 发送对象:-
StateP randomState = HeuristicSolverUtility.createRandom(Constants.DIMENSION , Constants.w1);
MPI.COMM_WORLD.Isend(randomState , 0 , 1 , MPI.OBJECT , 3 , Constants.STARTOPERATION);
或者使用,从这个答案here,以这种形式
StateP[] stateArray = new StateP[1];
stateArray[0] = randomState;
MPI.COMM_WORLD.Isend(stateArray , 0 , 1 , MPI.OBJECT , 3 , Constants.STARTOPERATION);
执行上述代码行时出现此异常:-
java.lang.reflect.InvocationTargetException
Caused by: mpi.MPIException: mpi.MPIException: java.lang.ClassCastException: common.model.StateP cannot be cast to [Ljava.lang.Object;
at mpi.Comm$9.handleCompletion(Comm.java:1678)
StateP 类是可序列化的
public class StateP implements State , Serializable
{
这里没有可接受的解决方案:-使用 MPJ express 发送对象
投票最多的答案对我不起作用。我该如何纠正这个,我做错了什么?
如果需要,这是我的 MPJ.IReceive 函数
StateP startingState = HeuristicSolverUtility.generateGoalState(Constants.DIMENSION, Constants.w1);
Request request = MPI.COMM_WORLD.Irecv(startingState, 0, 1, MPI.OBJECT, 0, Constants.STARTOPERATION);
request.Wait();