Menu

#56 Using variables for the decision variables bounds (lower,upper).

Any Version
open
nobody
None
5
2015-12-14
2015-12-13
Anonymous
No

Hi
Is it possible to set the decision variables bounds (lower & upper) to a variables declared somewhere else in my program out side the newSolution method ?????

like this
solution.setVariable(i, EncodingUtils.newReal(small,large));

and the variables small and large are declared and assigned values out side the newSolution method().

Discussion

  • Anonymous

    Anonymous - 2015-12-14

    You could try extending the RealVariable class and overriding the getLowerBound() and getUpperBound() methods.

     
    • Anonymous

      Anonymous - 2015-12-19

      Hi, Thank you for the reply
      Due of being a new user of Java as well MOEA, please can you provide me with more details about how to extend the RealVariable class .

      This is part of my code

      @Override
      public void evaluate (Solution solution) {
      .....
      .....
      // finding the smallest and largest numbers in the data set
      largest = points [0] [0] ;
      smallest = points [0] [0] ;
      for (int i = 0; i < 40; ++i)
      {
      for (int j = 0; j < 3; ++j)
      {
      if(points[i] [j] > largest)
      largest = points[i] [j];
      else if (points[i] [j] < smallest)
      smallest = points[i] [j];
      }
      }
      ............
      ............
      @Override
      public Solution newSolution ()
      {
      Solution solution = new Solution(numberOfVariables,
      numberOfObjectives);
      for(int i=0; i< numberOfVariables; i++)
      {
      solution.setVariable(i, new RealVariable(smallest, largest));
      }
      return solution;
      }

      Thank you

       
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.