Package com.niacin.input

Examples of com.niacin.input.Solution


  public static ArrayList<Solution> generateNeighbours(Solution s)
  {
    ArrayList<Solution> neighbours = new ArrayList<Solution>();
    for (int i = 0; i < s.size(); i++)
    {
      Solution si = makeMove(s, Direction.increase, i);
      if (si != null)
        neighbours.add(si);
      Solution sd = makeMove(s, Direction.decrease, i);
      if (si != null)
        neighbours.add(sd);
    }
    return neighbours;
  }
View Full Code Here


    return neighbours;
  }

  private static Solution makeMove(Solution original, Direction dir, int varNum)
  {
    Solution sol = (Solution) original.clone();
    sol.setEvaluated(false);
    Variable<?> v = sol.get(varNum);
    Variable<?> changed = null;
    switch (dir)
    {
      case increase :
        changed = v.increase();
        break;
      case decrease :
        changed = v.decrease();
        break;
    }
    if (changed != null)
    {
      sol.set(varNum, v.increase());
      return sol;
    }
    else
      return null;
  }
View Full Code Here

  }

  @Subscribe
  public void injectInput(InjectInputEvent event) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
  {
    Solution nextSolution = metaheuristic.getNextInput(problem);
    for (Variable<?> variable : nextSolution)
    {
      Method setter = setterMap.get(variable.name());
      setter.invoke(event.getSource(), new Object[]{variable.current()});
    }
View Full Code Here

    this.remainingTrials = trials;
  }

  public Solution initialSolution()
  {
    Solution initial = new Solution();
    initial.addAll(variables);
    return initial;
  }
View Full Code Here

    return initial;
  }

  public Solution generateRandomRestart()
  {
    Solution random = new Solution();
    for (Variable<?> v : variables)
    {
      random.add(v.random());
    }
    return random;
  }
View Full Code Here

    IntegerVariable v = IntegerVariable.parse(m);

    Variable<?> p = v;
    System.out.println(gson.toJson(p));

    Solution s = new Solution();
    s.add(p);
    System.out.println(gson.toJson(s));

    XStream xstream = new XStream(new DomDriver());
    String xml = xstream.toXML(s);
    System.out.println(xml);

    Solution s2 = (Solution) xstream.fromXML(xml);
    System.out.println(xstream.toXML(s2));
  }
View Full Code Here

    IntegerVariable v = IntegerVariable.parse(m);
   
    Variable<Integer> p = v;
    System.out.println(gson.toJson(p));
   
    Solution s = new Solution();
    s.add(p);
    System.out.println(gson.toJson(s));
  }
View Full Code Here

TOP

Related Classes of com.niacin.input.Solution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.