MOEA 框架 - 实施方法有问题

MOEA Framework - trouble with implementing method

我正在使用 MOEA 框架,但在实施解决方法时遇到问题。我写了下面的代码:

public Solution newSolution(double[] Cond) {
    Solution solution = new Solution(Input.General_Inputs.Num_Of_Ppes, Input.General_Inputs.Num_objectives, Input.General_Inputs.Num_Constraints);
    for (int Num = 0; Num < Input.General_Inputs.Num_Of_Ppes; Num++) {
        if (Cond[Num] > 3) {
            solution.setVariable(Num, EncodingUtils.newInt(0, Input.General_Inputs.Num_Alt_Decision_variable[Num]));
        }
    }

    return solution;
}

但是,该方法不接受 Cond 矩阵作为输入,我遇到以下错误:The method newSolution(double[]) of type Optimization_Problem must override or implement a supertype method

有什么建议吗?

接口指定的newSolution方法Problemdoesn't accept any arguments to it.

很难说您下一步应该做什么,因为我不确定您的用例,我也不完全熟悉该框架。不过,您 可以 做两件事:

  • 重载该方法并为您的自定义 newSolution 方法提供默认传递值:

    public Solution newSolution() {
        return newSolution(new double[]{0.0});
    }
    
  • 与其传递数组,不如尝试将其附加到它的实例并在需要的地方使用它:

    private double[] condition;
    
    public void setCondition(double[] condition) {
        this.condition = condition;
    }
    
    // Here you can call your custom method with the parameter omitted
    // and rely only on the `condition` field.