2015-02-04 35 views
1

我正在使用MOEA框架,並且在實施解決方法方面存在問題。我寫了下面的代碼: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; 
} 

然而,該方法不接受電導率矩陣作爲輸入,我有以下錯誤:The method newSolution(double[]) of type Optimization_Problem must override or implement a supertype method

有什麼建議?

+0

這裏真正的問題是,你的主類或者擴展了抽象的東西或者實現了一個接口,而'newSolution'的簽名與你的不同。你能否提供你正在使用的類聲明? – Makoto

+0

感謝您的回覆我正在考慮調整org.moeaframework.core中的Solution方法;要這樣的公共解(INT numberOfVariables,INT numberOfObjectives, \t \t \t INT numberOfConstraints,雙[]電導率){ \t \t變量=新變量[numberOfVariables]; \t \t goals = new double [numberOfObjectives]; \t \t constraints = new double [numberOfConstraints]; \t \t attributes = new HashMap (); \t} –

回答

0

由接口Problemdoesn't accept any arguments to it.

這很難說,指定的newSolution方法你應該接下來做,因爲我不知道您的使用情況下,我也不是完全熟悉的框架。有兩件事情你可能要做,儘管

  • 超載的方法和您的自定義提供一個默認直通價值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.