Package cu.repsystestbed.algorithms

Examples of cu.repsystestbed.algorithms.Algorithm


      if(!(lastItem instanceof Graph))
      {
        throw new WorkflowException("Last item was not a graph.");
      }
     
      Algorithm alg = (Algorithm) item;
     
      if(!alg.assertGraph2ListenType((Graph) lastItem))
      {
        throw new WorkflowException("Failed preconditions: assertGraph2ListenType()");
      }
     
      alg.setGraph2Listen((Graph) lastItem);
     
      ((Graph) lastItem).addObserver(alg);
     
     
      if(item instanceof EvaluationAlgorithm)
View Full Code Here


        }
      }
     
      if(o instanceof EvaluationAlgorithm)
      {
        Algorithm alg = ((EvaluationAlgorithm) o).getWrappedAroundAlg();
        Util.assertNotNull(alg);
        if(alg instanceof ReputationAlgorithm)
        {
          if(repGraphs == null) repGraphs = new ArrayList<ReputationGraph>();
          alg = (ReputationAlgorithm) alg;
          repGraphs.add((ReputationGraph) alg.getGraph2Output());
        }
           
      }
    }
   
View Full Code Here

      }
     
      //TODO get rid of this evaluation algorithm design
      if(o instanceof EvaluationAlgorithm)
      {
        Algorithm alg = ((EvaluationAlgorithm) o).getWrappedAroundAlg();
        if(alg instanceof TrustAlgorithm)
        {
          alg = (TrustAlgorithm) alg;
          return (TrustGraph) alg.getGraph2Output();
        }
       
      }
    }
   
View Full Code Here

    if(addObservers)
    {
      Iterator it = observers.iterator();
      while(it.hasNext())
      {
        Algorithm alg = (Algorithm) it.next();
        try
        {
          clone.addObserver(alg);
        }
        catch(Exception e)
View Full Code Here

      {
        Util.assertNotNull(t_cp);
        logger.debug("Algorithm name is: " + t_algName);
        logger.debug("Algorithm cp is: " + t_cp);
             
        Algorithm alg = createAlgorithmInstance(t_cp);
        m_storage.put(new String(t_algName), alg);


      }
      else if(t_graphName != null)
View Full Code Here

 
  public Algorithm createAlgorithmInstance(String classPath) throws WorkflowParserException
  {
    try
    {
      Algorithm alg = (Algorithm) Util.newClass(classPath);
      return alg;
     
    }
    catch(Exception e)
    {
View Full Code Here

            {
              throw new WorkflowParserException(algName.trim() + ".classpath setting not found.", e);
            }
           
            logger.debug("Algorithm class: " + classPath);
            Algorithm alg = createAlgorithmInstance(classPath);
            Util.assertNotNull(alg);
           
            String propLocation = m_properties.getProperty(algName.trim() + ".properties");
            if(propLocation != null)
            {
             
              Properties algProperties = new Properties();
              try
              {
                algProperties.load(new FileInputStream(propLocation));
                alg.setConfig(algProperties);
              }
              catch(Exception e)
              {
                logger.error("Cannot set algorithm properties.", e);
              }
             
            }
           
           
            /*
             * If it is a evaluation algorithm, then get .classpath and .evaluate settings.
             * Instantiate the inner algorithm and wrap it with the eval alg.
             */
            if(alg instanceof EvaluationAlgorithm)
            {
              String innerAlgName = m_properties.getProperty(algName.trim() + ".evaluate");
             
              try
              {
                Util.assertNotNull(innerAlgName);
              }
              catch(Exception e)
              {
                throw new WorkflowParserException(algName.trim() + ".evalute setting not found. An evaluation " +
                    "algorithm must wrap a reputation system testbed algorithm.", e);
              }
             
              logger.debug("Inner algorithm name: " + innerAlgName);
             
              String innerAlgClasspath = m_properties.getProperty(innerAlgName.trim() + ".classpath");
             
              try
              {
                Util.assertNotNull(innerAlgClasspath);
              }
              catch(Exception e)
              {
                throw new WorkflowParserException(".classpath setting not found for an algorithm. ", e);
              }
             
              logger.debug("Inner algorithm classpath: " + innerAlgClasspath);
              Algorithm innerAlg = createAlgorithmInstance(innerAlgClasspath);
              Util.assertNotNull(innerAlg);
             
              ((EvaluationAlgorithm) alg).wrap(innerAlg);
             
            }
View Full Code Here

 
  public Algorithm createAlgorithmInstance(String classPath) throws WorkflowParserException
  {
    try
    {
      Algorithm alg = (Algorithm) Util.newClass(classPath);
      return alg;
     
    }
    catch(Exception e)
    {
View Full Code Here

TOP

Related Classes of cu.repsystestbed.algorithms.Algorithm

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.