Examples of OrdinaryVariable


Examples of unbbayes.prs.mebn.OrdinaryVariable

    ResidentNode queryNode = mebn.getDomainResidentNode("isShipOfInterest");
   
    // Set up query
    List<OVInstance> ovInstanceList = new ArrayList<OVInstance>(1);
    List<Argument> arglist = queryNode.getArgumentList();
    OrdinaryVariable ov = arglist.get(0).getOVariable();
    OVInstance ovInstance = OVInstance.getInstance(ov,
        LiteralEntityInstance.getInstance("ship" + ship.getID(), ov.getValueType()));
    ovInstanceList.add(ovInstance);
    
    // Create query
    return new Query(queryNode, ovInstanceList);
  }
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

    ResidentNode queryNode = mebn.getDomainResidentNode("isShipOfInterest");
   
    // Set up query
    List<OVInstance> ovInstanceList = new ArrayList<OVInstance>(1);
    List<Argument> arglist = queryNode.getArgumentList();
    OrdinaryVariable ov = arglist.get(0).getOVariable();
    OVInstance ovInstance = OVInstance.getInstance(ov,
        LiteralEntityInstance.getInstance("ship" + ship.getID(), ov.getValueType()));
    ovInstanceList.add(ovInstance);
   
   
    // Create and run query
    Query query = new Query(queryNode, ovInstanceList);
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

       
        //For a input node IX1 that references the resident node RX1, we
        //should recover the ordinary variable of the RX1's HomeMFrag that
        //correspond to the OV of the IX1's MFrag and then set it to the
        //SSBNNode.
        OrdinaryVariable correspondentOV =
          nodeParent.getCorrespondentOrdinaryVariable(node.getOvArray()[i]);
       
        if(correspondentOV != null){
          newNode.setEntityForOv(
              correspondentOV,
              node.getEntityArray()[i]);
        }
      }
     
      //2. Create the new OVInstances for the combination
      for(int index = 0; index < ovFaultForNewNodeList.size(); index++){
       
        OrdinaryVariable correspondentOV =
          nodeParent.getCorrespondentOrdinaryVariable(ovFaultForNewNodeList.get(index));
       
        newNode.setEntityForOv(
            correspondentOV,
            LiteralEntityInstance.getInstance(possibleCombination[index],
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

    if(ovOrdereableList.size() < 1){
      throw new ImplementationRestrictionException(
          ImplementationRestrictionException.RV_NOT_RECURSIVE);
    }
   
    OrdinaryVariable ovOrdereable = ovOrdereableList.get(0); //Have only one element...
   
    //2) FIND THE PREVIOUS ELEMENT.
    ObjectEntity objectEntityOrdereable = residentNode.getMFrag().
                        getMultiEntityBayesianNetwork().getObjectEntityContainer().
                        getObjectEntityByType(ovOrdereable.getValueType());
 
    LiteralEntityInstance ovOrdereableActualValue = node.getEntityForOv(ovOrdereable);
    OVInstance ovInstanceOrdereable = OVInstance.getInstance(ovOrdereable, ovOrdereableActualValue);
   
    if(ovInstanceOrdereable == null){
      throw new SSBNNodeGeneralException();
    }
   
    String nameEntity = ovInstanceOrdereable.getEntity().getInstanceName();
   
    ObjectEntityInstanceOrdereable objectEntityInstanceOrdereable =
      (ObjectEntityInstanceOrdereable)objectEntityOrdereable.getInstanceByName(nameEntity);
   
    if(objectEntityInstanceOrdereable == null){
      throw new SSBNNodeGeneralException();
    }
   
    ObjectEntityInstanceOrdereable prev = objectEntityInstanceOrdereable.getPrev();

    if(prev != null){

      level5 = new IdentationLevel(level4);
      if (ssbn.getLogManager() != null) {
        ssbn.getLogManager().printText(level5, false, "Previous node = " + prev + " (" + objectEntityInstanceOrdereable + ")");
      }
     
      LiteralEntityInstance ovOrdereablePreviusValue =
        LiteralEntityInstance.getInstance(prev.getName(), ovOrdereable.getValueType());

      //3) Mount the father

      /*
       * Nota: uma pequena restrição aqui (fácil de ser retirada entretanto):
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

     
      for(String possibleValue: possibleValuesArray){
        entityValuesArray.add(new String[]{possibleValue});
      }
                                                                       
      OrdinaryVariable ovArray[] = new OrdinaryVariable[1];
      ovArray[0] = ov;
     
      try {
        mFragInstance.addOVValuesCombination(ovArray, entityValuesArray);
      } catch (MFragContextFailException e) {
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

     * @see unbbayes.io.mebn.LoaderPrOwlIO#loadDomainMFrag()
     */
    protected void loadDomainMFrag() throws IOMebnException {

      MFrag domainMFrag;
      OrdinaryVariable oVariable;
      ContextNode contextNode;
      ResidentNode domainResidentNode;
      InputNode generativeInputNode;
      BuiltInRV builtInRV;

      RDFIndividual individualOne;
      RDFIndividual individualTwo;
      OWLNamedClass owlNamedClass;
      OWLObjectProperty objectProperty;

      owlNamedClass = getOwlModel().getOWLNamedClass(DOMAIN_MFRAG);
      Collection instances = owlNamedClass.getInstances(false);

      for (Iterator it = instances.iterator(); it.hasNext();) {
        individualOne = (RDFIndividual) it.next();
        domainMFrag = getMapDomainMFrag().get(individualOne.getBrowserText());
        if (domainMFrag == null) {
          throw new IOMebnException(
              getResource().getString("DomainMFragNotExistsInMTheory"),
              individualOne.getBrowserText());
        }

        Debug.println("DomainMFrag loaded: "
            + individualOne.getBrowserText());

        domainMFrag.setDescription(getDescription(individualOne));

        /* -> hasResidentNode */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasResidentNode");
        instances = individualOne.getPropertyValues(objectProperty);
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          Object itInNext = itIn.next();
          if (!(itInNext instanceof RDFIndividual)) {
            try {
              System.err.println(itInNext + " != RDFIndividual");
            } catch (Throwable t) {
              t.printStackTrace();
            }
            continue;
          }
          individualTwo = (RDFIndividual) itInNext;

          // remove prefixes from the name
          String name = individualTwo.getBrowserText();
          if (name.startsWith(SaverPrOwlIO.RESIDENT_NAME_PREFIX)) {
            try {
              name = name.substring(SaverPrOwlIO.RESIDENT_NAME_PREFIX
                  .length());
            } catch (Exception e) {
              // ignore, because we can still try the original name
              e.printStackTrace();
            }
          }

          // instanciate a continuous resident node instead of resident node, if individual is assignable to a continuous node
          if (individualTwo.hasRDFType(getOwlModel().getOWLNamedClass(CONTINUOUS_RESIDENT_NODE), true)) {
            domainResidentNode = new ContinuousResidentNode(name, domainMFrag);
//            try {
//              ((ContinuousResidentNode)domainResidentNode).onAddToMFrag(domainMFrag);
//            } catch (MFragDoesNotExistException e) {
//              e.printStackTrace();
//            }
          } else {
            domainResidentNode = new ResidentNode(name, domainMFrag);
          }
          getMebn().getNamesUsed().add(name);

          domainMFrag.addResidentNode(domainResidentNode);

          // the mappings uses the original names (no prefix removal)
          getMapDomainResidentNode().put(individualTwo.getBrowserText(),
              domainResidentNode);
          getMapMultiEntityNode().put(individualTwo.getBrowserText(),
              domainResidentNode);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasInputNode */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasInputNode");
        instances = individualOne.getPropertyValues(objectProperty);
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          generativeInputNode = new InputNode(
              individualTwo.getBrowserText(), domainMFrag);
          getMebn().getNamesUsed().add(individualTwo.getBrowserText());
          domainMFrag.addInputNode(generativeInputNode);
          getMapGenerativeInputNode().put(individualTwo.getBrowserText(),
              generativeInputNode);
          getMapMultiEntityNode().put(individualTwo.getBrowserText(),
              generativeInputNode);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasContextNode */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasContextNode");
        instances = individualOne.getPropertyValues(objectProperty);
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          contextNode = new ContextNode(individualTwo.getBrowserText(),
              domainMFrag);
          getMebn().getNamesUsed().add(individualTwo.getBrowserText());
          domainMFrag.addContextNode(contextNode);
          getMapContextNode().put(individualTwo.getBrowserText(), contextNode);
          getMapMultiEntityNode().put(individualTwo.getBrowserText(),
              contextNode);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasOVariable */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasOVariable");
        instances = individualOne.getPropertyValues(objectProperty);
        String ovName = null;
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          ovName = individualTwo.getBrowserText(); // Name of the OV
                                // individual
          // Remove MFrag name from ovName. MFrag name is a scope
          // identifier
          try {
            ovName = ovName.split(domainMFrag.getName()
                + this.getOrdinaryVarScopeSeparator())[1];
          } catch (java.lang.ArrayIndexOutOfBoundsException e) {
            // Use the original name...
            ovName = ovName; // If its impossible to split, then no
                      // Scope id was found
          }
          // Debug.println("> Internal OV name is : " + ovName);
          // Create instance of OV w/o scope identifier
          oVariable = new OrdinaryVariable(ovName, getMebn()
              .getTypeContainer().getDefaultType(), domainMFrag);
          domainMFrag.addOrdinaryVariable(oVariable);
          // let's map objects w/ scope identifier included
          getMapOVariable().put(individualTwo.getBrowserText(), oVariable);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

        DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath
        .getLastPathComponent();
       
        if (node.isLeaf()) {
         
          OrdinaryVariable ordinaryVariable = ordinaryVariableMap.get(node);
         
          if (e.getModifiers() == MouseEvent.BUTTON3_MASK) {
            oVariableSelected = null;
          } else if (e.getClickCount() == 2
              && e.getModifiers() == MouseEvent.BUTTON1_MASK) {
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

       
        TreePath selPath = getPathForLocation(e.getX(), e.getY());
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath
        .getLastPathComponent();
       
        OrdinaryVariable ordinaryVariable = ordinaryVariableMap.get(node);
             
        if (node.isLeaf() && (ordinaryVariable != null)) {
       
          if (e.getModifiers() == MouseEvent.BUTTON3_MASK) {
           
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

          }
         
          ObjectEntityInstance arguments[] = finding.getArguments();
          List<OVInstance> ovInstanceList = new ArrayList<OVInstance>();
          for(int i = 0; i < arguments.length ; i++){
            OrdinaryVariable ov = residentNode.getArgumentNumber(i + 1).getOVariable();
            LiteralEntityInstance lei = LiteralEntityInstance.getInstance(arguments[i].getName() , ov.getValueType());
            ovInstanceList.add(OVInstance.getInstance(ov, lei));
          }
         
          SimpleSSBNNode ssbnNode = SimpleSSBNNode.getInstance(residentNode);
         
          for(OVInstance argument : ovInstanceList){
            ssbnNode.setEntityForOv(argument.getOv(), argument.getEntity());  
          }
          ssbnNode = ssbn.addSSBNNodeIfItDontAdded(ssbnNode);
         
          ssbnNode.setState(finding.getState());
          ssbnNode.setFinished(false);
         
          ssbn.addFindingToTheFindingList(ssbnNode);
        }
      }
    }
   
    if (logManager != null) {
      logManager.skipLine();
      logManager.printText(null, false, getResourceForHybridAlgorithm().getString("010_StepFinished"));
      logManager.skipLine();
      logManager.printSectionSeparation();
    }
   
    // add continuous nodes to the list of initial nodes
    if (isToAddAllContinuousNodes()) {
      for(MFrag mfrag: mebn.getMFragList()){
        // we are creating one continuous SSBN node per each possible combination of arguments in a continuous resident node
        for (Node node : mfrag.getNodes()) {
          if (node instanceof ContinuousResidentNode) {
           
            ContinuousResidentNode continuousResidentNode = (ContinuousResidentNode) node;
            if (continuousResidentNode.getOrdinaryVariableList() == null
                || continuousResidentNode.getOrdinaryVariableList().isEmpty()) {
              continue// go to next node
            }
           
            // prepare all possible combinations of arguments. The ovs are synchronized by index
            boolean hasAtLeastOneCombination = true// true if all Lists in combinator were filled
            List<List<LiteralEntityInstance>> combinator = new ArrayList<List<LiteralEntityInstance>>();
            for (OrdinaryVariable ov : continuousResidentNode.getOrdinaryVariableList()) {
              List<LiteralEntityInstance> contentOfCombinator = new ArrayList<LiteralEntityInstance>();
              // get all values for ov
              List<String> ovValues = knowledgeBase.getEntityByType(ov.getValueType().getName());
              if (ovValues.isEmpty()) {
                // this iterator cannot be filled, because ov has no possible values
                hasAtLeastOneCombination = false;
                break;
              }
              // add all possible values for ov
              for (String ovValue : ovValues) {
                contentOfCombinator.add(LiteralEntityInstance.getInstance(ovValue, ov.getValueType()));
              }
              combinator.add(contentOfCombinator);
            }
           
            // do not add node if there is some ov with no possible value (that means, no combination can be created)
View Full Code Here

Examples of unbbayes.prs.mebn.OrdinaryVariable

      });
   
      btnDown.addActionListener(
          new ActionListener(){
            public void actionPerformed(ActionEvent ae){
              OrdinaryVariable ov = treeMFrag.getOVariableSelected();
              if (ov != null){
                try{
                   mebnController.addOrdinaryVariableInResident(ov);
                }
                catch(OVariableAlreadyExistsInArgumentList e1){
                  JOptionPane.showMessageDialog(null, resource.getString("oVariableAlreadyIsArgumentError"), resource.getString("operationError"), JOptionPane.ERROR_MESSAGE);
                }
                catch(ArgumentNodeAlreadySetException e2){
                  e2.printStackTrace();
                }
              }
            }
          }
      );
     
    btnNew.addActionListener(
        new ActionListener(){
          public void actionPerformed(ActionEvent ae){
           
            try{
               OrdinaryVariable ov = mebnController.addNewOrdinaryVariableInResident();
              treeResident.setOVariableSelected(ov);
              txtName.setText(ov.getName());
              txtName.selectAll();
              txtName.requestFocus();
               treeMFrag.updateTree();
                treeResident.updateTree();
            }
          catch(OVariableAlreadyExistsInArgumentList e1){
              JOptionPane.showMessageDialog(null, resource.getString("oVariableAlreadyIsArgumentError"), resource.getString("operationError"), JOptionPane.ERROR_MESSAGE);
          }
          catch(ArgumentNodeAlreadySetException e2){
            e2.printStackTrace();
          }
          }
        }
    );
   
    btnDel.addActionListener(
          new ActionListener(){
            public void actionPerformed(ActionEvent ae){
              OrdinaryVariable ov = treeResident.getOVariableSelected();
              if (ov != null){
                  mebnController.removeOrdinaryVariableInResident(ov);
              }
            }
          }
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.