code: public void addObjective(Objective<? super SolutionType, ? super DataType> objective, double weight) {
          // check weight
          if(weight > 0.0){
              // add objective to map
              weights.put(objective, weight);
          } else {
              throw new IllegalArgumentException("Error in weighted index: each objective's weight should be strictly positive.");
          }
      }
docs: Add an objective with corresponding weight. Any objective designed for the solution type and data type of this
  multi-objective (or for more general solution or data types) can be added. The specified weight should be strictly
  positive, if not, an exception will be thrown.
  
  @param objective objective to be added
  @param weight corresponding weight (strictly positive)
  @throws IllegalArgumentException if the specified weight is not strictly positive