Package hu.u_szeged.nbo.client.model

Examples of hu.u_szeged.nbo.client.model.ResourceAllocation


     
      for (Iterator iterator = selection.iterator(); iterator.hasNext();) {
              domain = (Model) iterator.next();
             
              if (domain instanceof ResourceAllocation) {
          ResourceAllocation ra = ((ResourceAllocation)domain);
         
          if ((ra.isStarted()) && (!ra.isFailed())) {
            ClientLogManager.addUserLog("You are going to solve " + ra.getName() + " [#" + ra.getUniqueID() + "]"
                + " that already started/solved! Start solving first!", true);
           
            continue;
          }
           
          if (!ra.isSolved()) {
            ra.clearStates();
          }
         
          if (!ra.getAlgorithm().equals("none")) {
            if ((ra.getAlgorithm().equals("greedy4")) && (ra.getAlgParams().get("m") == null)) {
              ClientLogManager.addUserLog("You've missed to specify a positive m for problem " + ra.getName() + "!", true);
             
              return;
            }
           
            ra.solve();
            ra.setState(Model.STARTED);
            ra.setStartTime(System.currentTimeMillis());
           
            new SolutionMonitorThread(mainWindow, (Model)domain).start();
           
            ClientLogManager.addUserLog("Problem " + ra.getName() + " [#" + ra.getUniqueID() + "]"
                + " is started to solve with " + ra.getAlgorithm() + " algorithm.", false);
          }
                   
          else {
            ClientLogManager.addUserLog("No solver algorithm selected for problem " + ra.getName() + "!", true);
           
            return;
          }
         
          ra.updateSummary();
          mainWindow.getRAPerspective().setSummaryText(ra.getSummary());
         
        }
     
        mainWindow.getEventCentral().updateActionStates();
      }
View Full Code Here


     
    if (!selection.isEmpty()) {
      Model model = (Model)selection.getFirstElement();
           
          if (model instanceof ResourceAllocation) {
            ResourceAllocation raProblem = (ResourceAllocation)model;
           
            fileDialog.setFileName(raProblem.getName() + "_" + raProblem.getAlgorithm());
          }
         
          else fileDialog.setFileName(((Model)model).getName());
     
      fileDialog.open();
     
      if (fileDialog.getFilterPath().equals(""))
        return;
     
      String outPath = fileDialog.getFilterPath() + File.separator + fileDialog.getFileName();
     
      if (model instanceof ResourceAllocation) {
            ResourceAllocation raProblem = (ResourceAllocation)model;
            FileWriter fw;
           
            try {
              for (String key: raProblem.getSolution().keySet()) {             
                fw = new FileWriter(new File(outPath + "_" + key.replaceAll(".txt", "").replaceAll(raProblem.getName(), "szoveges") + ".txt"));
                fw.write(raProblem.getSolution().get(key));
                fw.close();
              }
             
              fw = new FileWriter(new File(outPath + "_algoritmus_naplo.txt"));
              fw.write(raProblem.getLog());
              fw.close();
             
              ClientLogManager.addUserLog(" Solution and log successfully saved to: " + fileDialog.getFilterPath(), false);
        }
       
View Full Code Here

        IStructuredSelection selection =
          (IStructuredSelection)mainWindow.getProblemBrowserTree().getTreeViewer().getSelection();

        if (selection.isEmpty()) return;

        ResourceAllocation raProblem = (ResourceAllocation)selection.getFirstElement();
       
        if (solverAlgorithm.equals("reschedule")) {
          if (!raProblem.getAlgParams().get("reschedulable").equals("true")) {
            ClientLogManager.addUserLog("Warning! You're going to solve " + raProblem.getName()
                + " with rescheduling without having the file 'kiindulas.txt'"
                + " added to the problem!", true);
          }
        }
       
        raProblem.setAlgorithm(solverAlgorithm);
        setSummaryText(raProblem.getSummary());
       
        mainWindow.getProblemBrowserTree().getTreeViewer().update(selection.getFirstElement(), null);
      }
    };
View Full Code Here

    if (!selection.isEmpty()) {
      for (Iterator iterator = selection.iterator(); iterator.hasNext();) {
        Object model = (Model)iterator.next();

        if ((model instanceof ResourceAllocation)) {
          ResourceAllocation ra = ((ResourceAllocation)model);

          if (!ra.isStarted()) {
            this.solveProblemAct.setEnabled(true);
            this.saveProblemAct.setEnabled(false);
            this.clearProblemAct.setEnabled(false);
          }

          else if (ra.isSolved()) {
            this.saveProblemAct.setEnabled(true);
            this.solveProblemAct.setEnabled(false);
            this.clearProblemAct.setEnabled(true);
          }

          else if((ra.isStarted()) && (ra.isFailed())) {
            this.solveProblemAct.setEnabled(true);
          }

          else {
            this.solveProblemAct.setEnabled(false);
View Full Code Here

      mainWindow.getShell().setText(((Model)domain).getName() + " - NBO Client 0.1");

      if (domain instanceof ResourceAllocation) {
        lastSelection = selection;

        ResourceAllocation ra = (ResourceAllocation)domain;
        ResourceAllocationPerspective perspective = mainWindow.getRAPerspective();

        String textSolution = ra.getSolution().get(ra.getName());
        String log = ra.getLog();

        mainWindow.changePerspective(perspective);

        perspective.setSummaryText(ra.getSummary());
        perspective.setSourceTables(ra);
        perspective.setSolutionTables(ra);


        if (perspective.getContent().getSelection() == null)
          perspective.getContent().setSelection(0);

        if (textSolution != null)
          perspective.setSolutionText(textSolution);
        else
          perspective.clearText();

        if (log != null)
          perspective.setServerOutputText(log);
        else
          perspective.clearText();

        if ((ra.isSolved() || ra.isFailed()) && !ra.isAcknowledged()) {
          ra.setState(Model.ACKNOWLEDGED);
          mainWindow.getProblemBrowserTree().getTreeViewer().refresh();
       

        if (ra.isStarted() && !ra.isFailed())  {
          perspective.getAlgSelector().setEnabled(false);
          perspective.getOptionsGroup().setEnabled(false);
        }

        else {
          perspective.getAlgSelector().setEnabled(true);
          perspective.getOptionsGroup().setEnabled(true);
        }

        Combo selector = perspective.getAlgSelector();
        Text mText =
          (Text)perspective.getOptionsGroup().getChildren()[ResourceAllocationPerspective.M_TEXT];
        Text l1Text =
          (Text)perspective.getOptionsGroup().getChildren()[ResourceAllocationPerspective.L1_TEXT];
        Text l2Text =
          (Text)perspective.getOptionsGroup().getChildren()[ResourceAllocationPerspective.L2_TEXT];
        Text KText =
          (Text)perspective.getOptionsGroup().getChildren()[ResourceAllocationPerspective.K_TEXT];
        Text rText =
          (Text)perspective.getOptionsGroup().getChildren()[ResourceAllocationPerspective.R_TEXT];

        selector.select(ra.getAlgorithmIndex(ra.getAlgorithm()));

        if (ra.getAlgorithm().equals("greedy4")) {
          String m = ra.getAlgParams().get("m");

          mText.setEnabled(true);

          if (m != null) mText.setText(m);
        }

        else {
          mText.setText("1");
          mText.setEnabled(false);
        }

        if (ra.getAlgorithm().equals("greedy1_delta4") || ra.getAlgorithm().equals("greedy3_delta4")) {
          String l1 = ra.getAlgParams().get("l1");
          String l2 = ra.getAlgParams().get("l2");

          l1Text.setEnabled(true);
          l2Text.setEnabled(true);

          if (l1 != null) l1Text.setText(l1);
          if (l2 != null) l2Text.setText(l2);
       

        else {
          l1Text.setEnabled(false);
          l1Text.setText("1");
          l2Text.setEnabled(false);
          l2Text.setText("1");
        }

        if (ra.getAlgorithm().equals("greedy2mod")) {
          String K = ra.getAlgParams().get("K");
          String r = ra.getAlgParams().get("r");

          KText.setEnabled(true);
          rText.setEnabled(true);

          if (K != null) KText.setText(K);
View Full Code Here

      (IStructuredSelection)mainWindow.getProblemBrowserTree().getTreeViewer().getSelection();

    if (selection.isEmpty()) return;

    else {
      ResourceAllocation raProblem = (ResourceAllocation)selection.getFirstElement();
      HashMap<String, String> raAlgParams = raProblem.getAlgParams();

      try {
        Float m = Float.parseFloat(text.getText());

        if (m <= 0) throw new NumberFormatException();
        else {
          raAlgParams.put(text.getData().toString(), m.toString());
        }

        text.setForeground(new Color(null, 0, 0, 0));
      }

      catch (NumberFormatException e) {
        ClientLogManager.addUserLog("Input characters must be integers and greater than 0!", true);
        text.setForeground(new Color(null, 255, 0, 0));
        raAlgParams.remove(text.getData().toString());
      }

      raProblem.updateSummary();
      mainWindow.getRAPerspective().setSummaryText(raProblem.getSummary());
    }
  }
View Full Code Here

              String success = "";

              if (selection.getFirstElement() == problem) {
                if (problem instanceof ResourceAllocation) {
                  ResourceAllocation raProblem = ((ResourceAllocation)problem);
                  ResourceAllocationPerspective perspective = mainWindow.getRAPerspective();

                  raProblem.setState(Model.ACKNOWLEDGED);
                  perspective.setSummaryText(raProblem.getSummary());
                  perspective.setSolutionText(finalTextSolution);
                  perspective.setSolutionTables((ResourceAllocation)problem);
                  perspective.setServerOutputText(log);
                 
                  perspective.getAlgSelector().setEnabled(false);
View Full Code Here

            for (String fileInDir: directory.list()) {
              String data = readFile(new File(directoryName + File.separator + fileInDir));
              geomInput.put(fileInDir, data);
            }
             
            ResourceAllocation problem
              = new ResourceAllocation(directory.getName(), userName, geomInput);
           
            problem.addAlgParam("reschedulable", reschedulable.toString());
                         
            problemTree.add(problem);

            ClientLogManager.addUserLog("Problem " + directory.getName() + " opened successfully from " + directory.getParent() + ".", false);
          }
View Full Code Here

  public Image getImage(Object element) {
    Image image = null;

    switch (((Model)element).getType()) {
    case Model.RES_ALLOC:
      ResourceAllocation raProblem = (ResourceAllocation)element;

      if (raProblem.isSolved())
        image = im.getImage("res_alloc_solved.png");
      else if (raProblem.isFailed())
        image = im.getImage("res_alloc_failed.png");
      else if ((raProblem.isSentToServer()) && (!raProblem.isSolved()))
        image = im.getImage("res_alloc_sent.png");
      else if (raProblem.isStarted())
        image = im.getImage("res_alloc_started.png");
      else {
        image = im.getImage("res_alloc.png");
      }
      break;
View Full Code Here

  public String getText(Object element) {
    String label = element.toString();

    if (!(element instanceof Problem)) {
      if (element instanceof ResourceAllocation) {
        ResourceAllocation raProblem = ((ResourceAllocation)element);
        label += " - [#" + raProblem.getUniqueID() + "] - " + raProblem.getAlgorithm();
      }
    }
   
    return label; 
  }
View Full Code Here

TOP

Related Classes of hu.u_szeged.nbo.client.model.ResourceAllocation

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.