@SuppressWarnings("unchecked")
 public MLNModel integrateModel(MLNModel mlnModel) {
   Class<? extends MLNNamedObject> mlnNamedObjectClass;
   Class<? extends MLNObject> mlnObjectClass;
   if (!(mlnModel.equals(this))) {
     Map<Class<?>, List<MLNObject>> mlnObjects = mlnModel.getMlnObjects();
     Map<Class<?>, Map<String, MLNNamedObject>> mlnNamedObjects = mlnModel.getMlnNamedObjects();
     for (Class<?> mlnClass : mlnObjectClasses) {
       if (MLNNamedObject.class.isAssignableFrom(mlnClass)) {
         mlnNamedObjectClass = (Class<? extends MLNNamedObject>) mlnClass;
         for (Object obj : mlnNamedObjects.get(mlnClass).values()) {
           addMlnNamedObject((mlnNamedObjectClass).cast(obj));
         }
       } else {
         mlnObjectClass = (Class<? extends MLNObject>) mlnClass;
         for (Object obj : mlnObjects.get(mlnClass)) {
           addMlnObject((mlnObjectClass).cast(obj));
         }
       }
     }
   }
   return mlnModel;
 }
 public void transferWeights(MLNModel weightModel, boolean skipLE) {
   List<MLNFormula> formulasToRemove = new ArrayList<MLNFormula>();
   boolean transfered;
   List<MLNFormula> formulasToAdd = new ArrayList<MLNFormula>();
   for (MLNFormula weightFormula : weightModel.getWeightedFormulas()) {
     transfered = false;
     if (weightFormula.getProbabilityWeight() != null
         || weightFormula.getUtilityWeight() != null) {
       for (MLNFormula targetFormula : getAll(MLNFormula.class)) {
         if (weightFormula
             .getPlainFormula()
             .contentEquals(targetFormula.getPlainFormula(), false, false)) {
           targetFormula.setProbabilityWeight(weightFormula.getProbabilityWeight());
           targetFormula.setUtilityWeight(weightFormula.getUtilityWeight());
           transfered = true;
           break;
         } else if (!targetFormula.isHardRule() && targetFormula.getProbabilityWeight() == null)
           targetFormula.setProbabilityWeight(buildMLNWeight(0.0));
       }
     }
     if (!transfered) {
       formulasToAdd.add(weightFormula);
     }
   }
   for (MLNFormula quantifiedFormula : getQuantifiedFormulas()) {
     if (quantifiedFormula.getPlainFormula() != null
         && quantifiedFormula.getPlainFormula().getQuantification() != null
         && quantifiedFormula
             .getPlainFormula()
             .getQuantification()
             .getRelation()
             .equals(MLNRelation.LE)
         && skipLE) {
       formulasToRemove.add(quantifiedFormula);
     }
   }
   for (MLNFormula formula : formulasToRemove) removeMlnObject(formula);
   for (MLNFormula formula : formulasToAdd) {
     addMlnObject(formula);
   }
 }