Package de.hwrberlin.it11.tsp.controller

Examples of de.hwrberlin.it11.tsp.controller.AntController


  /**
   * Setzte das Bild des L�sungsdateiakzeptanz-Labels entsprechend der Validit�t der L�sungsdatei. Die L�sungsdatei ist genau dann valide, wenn sie
   * die gleiche L�nge wie die Liste der Knoten aufweist.
   */
  private void evaluateSolutionAccept() {
    AntProject project = getController().getProject();
    if (project.getOptimalTourIndeces() == null || (project.getOptimalTourIndeces().size() - 1 != project.getTSPData().getNodeList().size())) {
      _lAccept.getLabel().setImage(Images.CROSS);
    }
    else {
      _lAccept.getLabel().setImage(Images.TICK);
    }
View Full Code Here


            // Jede Ameise platziert Pheromone auf den Kanten, die sie besucht hat
            for (Ant ant : antList) {
              for (int j = 0; j < ant.getVisitedNodes().size() - 1; j++) {
                Node node = ant.getVisitedNodes().get(j);
                Node otherNode = ant.getVisitedNodes().get(j + 1);
                Edge edge = node.getEdge(otherNode);
                edge.setPheromone(edge.getPheromone() + _project.getParameter().getPheromonUpdateParameter()
                    / ant.getTravelledDistance());
              }
            }

            // Berechnung der Durchschnittswerte der Tourl�ngen
View Full Code Here

   * Testet das Hinzuf�gen einer Node zum Projekt.
   */
  public void testNodeAdd() {
    TSPData data = new TSPData();
    int count = data.getNodeList().size();
    data.addNode(new Node(0, 0));
    assertTrue(count + 1 == data.getNodeList().size());
  }
View Full Code Here

  /**
   * Testet das L�schen einer Node aus dem Projekt.
   */
  public void testNodeRemove() {
    TSPData data = new TSPData();
    Node node = new Node(0, 0);
    data.addNode(node);
    int count = data.getNodeList().size();
    data.removeNode(node);
    assertTrue(count - 1 == data.getNodeList().size());
  }
View Full Code Here

  /**
   * Testet das Bewegen einer Node.
   */
  public void testNodeMove() {
    TSPData data = new TSPData();
    Node node = new Node(100, 100);
    data.addNode(node);
    node.setxCoordinate(150);
    node.setyCoordinate(30);
    assertTrue(node.getxCoordinate() == 150);
    assertTrue(node.getyCoordinate() == 30);
  }
View Full Code Here

            }
            if (maxY == 0) {
              maxY = (int) (Math.random() * 4999) + 1;
            }
            for (int i = 0; i < nodeCount; i++) {
              Node node = new Node(Math.random() * maxX, Math.random() * maxY);
              nodeList.add(node);
            }

            _result = new TSPData();
            _result.setName("Zufallsprojekt");
View Full Code Here

      @Override
      public void widgetSelected(SelectionEvent pE) {
        if (tXCoordinate.isValidInput() && tYCoordinate.isValidInput()) {
          try {
            _result = new Node(Utility.FORMAT.parse(tXCoordinate.getText().getText()).doubleValue(), Utility.FORMAT.parse(
                tYCoordinate.getText().getText()).doubleValue());
          }
          catch (ParseException e) {
            MessageDialog.openError(shell, "Fehler beim umwandeln der Werte",
                "Beim Umwandeln der Werte von Text in eine Zahl ist ein Fehler aufgetreten.");
View Full Code Here

            }
            AntProject project = getController().getProject();
            double zoomFactor = project.getParameter().getZoomFactor();
            NewNodeDialog newNodeDialog = new NewNodeDialog(getShell(), project, (pE.x - BORDER_WIDTH) / zoomFactor,
                (pE.y - BORDER_WIDTH) / zoomFactor);
            Node newNode = newNodeDialog.open();
            if (newNode != null) {
              project.getTSPData().addNode(newNode);
            }
          }
        }
View Full Code Here

      _canvas.setBackground(preferences.getBackgroundColor());

      // Beste Tour Iteration
      pE.gc.setForeground(preferences.getBestTourIterationColor());
      for (int i = 0; i < result.getBestTourIteration().size() - 1; i++) {
        Node node = result.getBestTourIteration().get(i);
        Node otherNode = result.getBestTourIteration().get(i + 1);
        pE.gc.drawLine((int) (node.getxCoordinate() * zoomFactor) + BORDER_WIDTH, (int) (node.getyCoordinate() * zoomFactor) + BORDER_WIDTH,
            (int) (otherNode.getxCoordinate() * zoomFactor) + BORDER_WIDTH, (int) (otherNode.getyCoordinate() * zoomFactor)
                + BORDER_WIDTH);
      }
      // Beste Tour global
      pE.gc.setForeground(preferences.getBestTourGlobalColor());
      for (int i = 0; i < result.getBestTourGlobal().size() - 1; i++) {
        Node node = result.getBestTourGlobal().get(i);
        Node otherNode = result.getBestTourGlobal().get(i + 1);
        pE.gc.drawLine((int) (node.getxCoordinate() * zoomFactor) + BORDER_WIDTH, (int) (node.getyCoordinate() * zoomFactor) + BORDER_WIDTH,
            (int) (otherNode.getxCoordinate() * zoomFactor) + BORDER_WIDTH, (int) (otherNode.getyCoordinate() * zoomFactor)
                + BORDER_WIDTH);
      }
      // Nodes
      pE.gc.setBackground(preferences.getNodeColor());
      for (Node node : nodeList) {
View Full Code Here

          if (line.matches("\\s*EDGE_WEIGHT_TYPE\\s*:\\s*.+")) {
            edgeWeightType = line.split(":")[1].trim();
          }
          if (nodeSection) {
            String[] nodeData = line.split("\\s+");
            Node node = new Node(Double.parseDouble(nodeData[1]), Double.parseDouble(nodeData[2]));
            nodeList.add(node);
          }
          if (line.matches("\\s*NODE_COORD_SECTION.*")) {
            nodeSection = true;
          }
View Full Code Here

TOP

Related Classes of de.hwrberlin.it11.tsp.controller.AntController

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.