Examples of ResultPool


Examples of de.fzi.herakles.strategy.impl.anytime.ResultPool

   * @param unsoundIncompleteReasoner the unsound and incomplete reasoner
   */
  @SuppressWarnings("unchecked")
  private void variant(ReasonerAdapter positiveSoundReasoner, ReasonerAdapter negativeSoundReasoner,
      ReasonerAdapter completeReasoner, ReasonerAdapter soundCompleteReasoner, ReasonerAdapter unsoundIncompleteReasoner){
    ResultPool pool = new ResultPool();
    OWLClassExpression des = (OWLClassExpression) this.query.getParams()[0];
    OWLClassExpression negDes = des.getComplementNNF();
   
    Class<?>[] paramTypes = { OWLClassExpression.class, boolean.class };
    Object[] params = { negDes, false };
    Query negQuery;
        try {
            negQuery = QueryFactory.getQuery( "getIndividuals", paramTypes, params );
            int reasonerNumber = 0;
            if(positiveSoundReasoner != null){
                reasonerNumber++;
                positiveSoundReasoner.getReasonerProperties().setProperty("anytime_name", "SoundPositive");
                IReasonerThread soundPositiveThread = new IReasonerThread(pool, positiveSoundReasoner, query);
                soundPositiveThread.start();
            }
           
            if(negativeSoundReasoner != null){
                reasonerNumber++;
                negativeSoundReasoner.getReasonerProperties().setProperty("anytime_name", "SoundNegative");
                IReasonerThread soundNegativeThread = new IReasonerThread(pool, negativeSoundReasoner, negQuery);
                soundNegativeThread.start();
            }
           
            if(completeReasoner != null){
                reasonerNumber++;
                completeReasoner.getReasonerProperties().setProperty("anytime_name", "Complete");
                IReasonerThread completeThread = new IReasonerThread(pool, completeReasoner, query);
                completeThread.start();
            }
           
            if(soundCompleteReasoner != null){
                reasonerNumber++;
                soundCompleteReasoner.getReasonerProperties().setProperty("anytime_name", "SoundAndComplete");
                IReasonerThread soundCompleteThread = new IReasonerThread(pool, soundCompleteReasoner, query);
                soundCompleteThread.start();
            }
           
            if(unsoundIncompleteReasoner != null){
                reasonerNumber++;
                unsoundIncompleteReasoner.getReasonerProperties().setProperty("anytime_name", "UnsoundAndIncomplete");
                IReasonerThread unsoundIncompleteThread = new IReasonerThread(pool, unsoundIncompleteReasoner, query);
                unsoundIncompleteThread.start();
            }

            if(reasonerNumber == 0){
                this.listener.resultCompleted();
                if(logger.isInfoEnabled()){
                  logger.info("No reasoner is assigned!");
                }
                return;
            }
            ArrayList<Object> results = new ArrayList<Object>();

            while (results.size() < reasonerNumber) {
                AnytimeResult result = pool.readData();
                if (result != null) {
                    results.add(result);
                    setData(result.getReasoner(), (Set<OWLNamedIndividual>) result.getAnswer());
                    if(logger.isInfoEnabled()){
                      logger.info(result.getReasoner() + "finished with "
View Full Code Here

Examples of de.fzi.herakles.strategy.impl.anytime.ResultPool

    // soundReasoners.iterator().next();
    // screechSoundNegative.getReasonerProperties().setProperty( "name",
    // "ScreechSoundNegative" );
    // ((PropertyConstraintSelector) this.selector).clearConstraints();

    ResultPool pool = new ResultPool();

    IReasonerThread screechCompleteReasoner = new IReasonerThread(pool,
        screechComplete, query);
    IReasonerThread screechSoundPositiveReasoner = new IReasonerThread(
        pool, screechSoundPositive, query);
    // ScreechThread screechSoundNegativeReasoner = new
    // ScreechThread(pool,screechSoundNegative, negQuery );

    screechSoundPositiveReasoner.start();
    screechCompleteReasoner.start();
    // screechSoundNegativeReasoner.start();

    int reasonerNumber = 2;
    ArrayList<Object> results = new ArrayList<Object>();

    while (results.size() < reasonerNumber) {
      AnytimeResult result = pool.readData();
      if (result != null) {
        results.add(result);
        setData(result.getReasoner(), (Set<OWLNamedIndividual>) result
            .getAnswer());
        System.out.println(result.getReasoner() + ": "
View Full Code Here

Examples of de.fzi.herakles.strategy.impl.anytime.ResultPool

    }
    return null;
  }

  private void variant2() {
    ResultPool pool = new ResultPool();
    OWLClassExpression des = (OWLClassExpression) this.params[0];
    OWLClassExpression negDes = des.getComplementNNF();
   
    Class<?>[] paramTypes = { OWLClassExpression.class };
    Object[] params = { negDes };
    try {
            Query negQuery = QueryFactory.getQuery( "getIndividuals", paramTypes, params );
        } catch( IllegalArgumentException e ) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch( ClassCastException e ) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch( NoSuchMethodException e ) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
//    negQuery.serialise();

    Set<ReasonerAdapter> availableReasoners = registry.getAsSet(true, true);


    IReasonerThread screechSoundPositive = getReasoner(availableReasoners,
        "remoteScreechNone1", "ScreechSoundPositive", query, pool);
   
    IReasonerThread screechComplete = getReasoner(availableReasoners,
        "remoteScreechAll", "ScreechComplete", query, pool);

    screechSoundPositive.start();
    screechComplete.start();

    int reasonerNumber = 2;
    ArrayList<Object> results = new ArrayList<Object>();

    while (results.size() < reasonerNumber) {
      AnytimeResult result = pool.readData();
      if (result != null) {
        results.add(result);
        setData(result.getReasoner(), (Set<OWLNamedIndividual>) result
            .getAnswer());
        System.out.println(result.getReasoner() + ": "
View Full Code Here

Examples of de.fzi.herakles.strategy.impl.anytime.ResultPool

    }
   
 
    Set<ReasonerAdapter> reasonerPool =  registry.getAsSet( true , true);
    // synchronisation pool
    ResultPool pool = new ResultPool();
   
    int reasonerNumber=0;
    for( ReasonerAdapter reasoner : reasonerPool ){
      if(reasoner.equals("remoteAQA")) {
          reasoner.getReasonerProperties().setProperty("name", "AQA" );
      }
      new IReasonerThread(pool,reasoner, query).start();
      reasonerNumber++;
    }


    ArrayList<Object> results = new ArrayList<Object>();
   
    while (results.size() < reasonerNumber) {
      AnytimeResult result = pool.readData();
      if(result!=null) {
        results.add(result);
        setData(result.getReasoner(),(Set<OWLNamedIndividual>)result.getAnswer());
        System.out.println(result.getReasoner() + ": " + ((HashSet)result.getAnswer()).size()+" finished!");
      }
View Full Code Here

Examples of mephi.cybernetics.dhcn.common.data.result.ResultPool

                {
                    System.out.println("Task");
                    DataTask task = (DataTask)message;
                    if (task.getTypeNode() == Config.NODE_CLIENT)
                    {
                        this.pools.add(new ResultPool(1, task.getTaskId(), this.counterPoolId, task.getNodeId(), true, task.getNumOfMessage()));
                        task.setTargetId(this.counterPoolId);
                        this.counterPoolId++;
                    }
                    switch (task.getTaskId())
                    {
                        case Config.MATRIX_MULT_NUM:
                        {
                            System.out.println("Matrix multi num");
                            break;
                        }
                        case Config.VECTOR_MULT_NUM:
                        {
                            System.out.println("Vector multi num");
                            break;
                        }
                        case Config.NUM_MULT_NUM:
                        {
                            System.out.println("Num multi num");
                            break;
                        }
                    }
                    if (!this.writeTask(task))
                    {
                        this.messages.add(message);
                    }
                    continue;
                   
                }
                if ( DataResult.class.isAssignableFrom(message.getClass()))
                {
                     DataResult result = (DataResult)message;
                     if (DataMatrixMultNumResult.class.isAssignableFrom(result.getClass()))
                     {
                          System.out.println("ResultMatrixMultiNum");
                     }
                     if (DataVectorMultNumResult.class.isAssignableFrom(result.getClass()))
                     {
                         System.out.println("ResultVectorMultiNum");
                     }
                     if (DataNumMultNumResult.class.isAssignableFrom(result.getClass()))
                     {
                         System.out.println("ResultNumMultiNum");
                     }
                    
                     ResultPool pool = searchPool(result.getIdTarget());
                     if (pool != null)
                     {
                         pool.addToPool(result);
                         nodeFree(result.getNodeId());
                         System.out.println("Add to pool");
                         if (pool.isFull())
                         {
                             if (pool.IsResultClient())
                             {
                                 this.writeMessage(pool.getElemPool(0), pool.getTargetId());
                                 this.pools.remove(pool);
                                 System.out.println("Size pool array: " + this.pools.size());
                             }
                             else
                             {
                                 this.messages.add(pool);
                                 this.pools.remove(pool);
                             }
                         }
                        
                     }
                    continue;
                }
                if ( ResultPool.class.isAssignableFrom(message.getClass()))
                {
                   System.out.println("Sent pool");
                   if(!this.writePool((ResultPool)message))
                   {
                       this.messages.add(message);
                   }
                   continue;
                }
               
                if ( MDispatcherID.class.isAssignableFrom(message.getClass()))
                {
                    MDispatcherID dispatcherId = (MDispatcherID)message;
                    this.id = dispatcherId.id;
                    continue;
                }

                if ( INodeInfo.class.isAssignableFrom(message.getClass()))
                {
                    if (NodeInfoSocket.class.isAssignableFrom(message.getClass()))
                    {
                        System.out.println("New Node");
                        NodeInfoSocket info = (NodeInfoSocket)message;
                        switch (info.getType())
                        {
                            case Config.NODE_CLIENT :
                            {
                                System.out.println("Client");
                                break;
                            }
                            case Config.NODE_SOLVER :
                            {
                                System.out.println("Solver");
                                break;
                            }
                            case Config.NODE_DISPATCHER :
                            {
                                System.out.println("Dispatcher");
                                break;
                            }
                        }
//                        INodeConfig config = null;
//                        if ((info.getType() == Config.NODE_CLIENT) || (info.getType() == Config.NODE_SOLVER))
//                        {
//                            config = new NodeConfigSocket(info.getIp(), info.getPort(), this.counterNodeId, info.getType(), info.getTaskTypes());
//                        }
//                        if (info.getType() == Config.NODE_DISPATCHER)
//                        {
//                            config = new NodeConfigSocket(info.getIp(), info.getPort(), this.counterNodeId, info.getType(), info.getTaskTypes());
//                            NodeInfoSocket dispatcherInfo = new NodeInfoSocket(this.ip, this.port, this.counterNodeId, null, this.id);
//                            this.manager.writeData(dispatcherInfo, config);
//                        }
                        INodeConfig config = new NodeConfigSocket(info.getIp(), info.getPort(), this.counterNodeId, info.getType(), info.getTaskTypes());
                        this.nodes.add(config);
                        counterNodeId++;
                    }
                    continue;
                }
               
                if ( NewPoolResultConfig.class.isAssignableFrom(message.getClass()))
                {
                   
                    NewPoolResultConfig config = (NewPoolResultConfig)message;
                    System.out.println("Pool new Size: "  + config.getSizePool() + "TaskId: " + config.getTaskId());
                    this.pools.add(new ResultPool(config.getSizePool(), config.getTaskId(), this.counterPoolId, config.getTargetId(), false, config.getNumOfMessage()));
                    for (int i = 0; i < config.getSizePool(); i++)
                    {
                        DataTask task = config.getTask(i);
                        task.setTargetId(this.counterPoolId);
                        this.messages.add(task);
View Full Code Here

Examples of mephi.cybernetics.dhcn.common.data.result.ResultPool

            return null;
        }
       
        if ( ResultPool.class.isAssignableFrom(data.getClass()))
        {
            ResultPool pool = (ResultPool)data;
            for (int i = 0; i < this.solvers.size(); i++)
            {
                if (pool.getTaskId() == solvers.get(i).getTaskId())
                {
                    return solvers.get(i).assembly(pool);
                }
            }
            return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.