MOEA框架 - 实施方法的麻烦

时间:2015-02-04 22:33:35

标签: java eclipse moea-framework

我正在使用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

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

接口newSolution doesn't accept any arguments to it.

指定的Problem方法

很难说你接下来要做什么,因为我不确定你的用例,我也不完全熟悉这个框架。但是,可以做两件事:

  • 重载方法并为您的自定义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.