MOEA Framework - trouble with implementing method

376 views Asked by At

I am working with the MOEA Framework, and I am having a problem in implementing a solution method. I wrote the following code:

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;
}

However, the method doesn't accept the Cond matrix as an input and I have the following error: The method newSolution(double[]) of type Optimization_Problem must override or implement a supertype method

Any suggestions?

1

There are 1 answers

0
Makoto On BEST ANSWER

The newSolution method as specified by the interface Problem doesn't accept any arguments to it.

It's difficult to say what you should do next, as I'm not sure of your use case, nor am I entirely familiar with the framework. There are two things you could do, though:

  • Overload the method and provide a default pass-through value to your custom newSolution method:

    public Solution newSolution() {
        return newSolution(new double[]{0.0});
    }
    
  • Instead of passing through the array, try instead to attach it to an instance of it and use that where you need to:

    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.