AssetStateDescriptor asset_sd = getAssetStateDescriptor ( asset_expanded_name,
AssetStateDimension asset_sd = getAssetStateDimension ( asset_expanded_name,
    public double getObsProbability( String asset_expanded_name,                                     String defense_name,                                     String monitoring_level,                                     String state_descriptor_name,                                     String state_descriptor_value,                                     String diagnosis_name )             throws BelievabilityException     {                if ( (LOCAL_DEBUG_LEVEL >= 5) && this._logger.isDebugEnabled())             this._logger.debug("getObsProb : "                               + "\n    asset=" + asset_expanded_name                                + ", defense=" + defense_name                                + ", mon-level=" + monitoring_level                               + ", asd=" + state_descriptor_name                               + "\n    Computing Pr( diag=" + diagnosis_name                                + " | state="                                + state_descriptor_value + ")");	// Get the asset TechSpec.	AssetTechSpecInterface atsi =	    getAssetModel( asset_expanded_name ).getAssetTS();                // Get the AssetStateDescriptor. This may throw a        // BelievabilityException        AssetStateDescriptor asset_sd =                 getAssetStateDescriptor ( asset_expanded_name,                                           state_descriptor_name );        // Get the DefenseTechSpecInterface. This may throw a        // BelievabilityException        DefenseTechSpecInterface defense_tsi =  	    getDefenseTS( defense_name, atsi.getAssetType().getName() );        // FIXME: Should we also be checking to see if this defense        // actually pertains to the asset we are trying to compute the        // belief for?  Maybe this is not necessary since we would not        // have gotten the TimedDefenseDiagnosis object for this asset        // if it wasn't relevant.  In the latter case maybe there        // should be a sanity check?         // *** FIX WHEN READY **MonitoringLevel ml =        // *** defense_tsi.getMonitoringLevel( monitoring_level );        MonitoringLevel ml =                 (MonitoringLevel)                 defense_tsi.getMonitoringLevels().firstElement();        Vector diagnosis_accuracy_functions = ml.getDiagnosisAccuracy();        // FIXME: Assumptions:         //        // The Pr( diag=OK | state ) is *NOT* explicitly        // represented in the defense tech specs.  The way we compute        // this is to find the Pr( diag=BAD | state ) and then        // subtracting it from 1.0.  The sticky issue is in the naming        // of the diagnoses.          //        // First, it is assumed that no matter what the Defense, one        // diagnosis name is "OK" and this is the "good" state.        // Second, it is assumed that there are only two possible        // diagnosis names, so any name that is not "OK" must be the        // name fo the "bad" diagnosis (which will be different for        // each defense).        //        String search_name;        double found_prob = 0.0;        boolean found = false;        // The name we search for is not always the same as the one we        // want the probability for (see assumption note above).        //        if ( diagnosis_name.equalsIgnoreCase( DIAGNOSIS_OK_STR ))            search_name =                     getBadDiagnosisName( diagnosis_accuracy_functions );        else            search_name = diagnosis_name;        if (this._logger.isDebugEnabled())             this._logger.debug("getObsProb : "                               + "Looking for defense="                               + defense_name                               + ", diagnosis=" + search_name );        // Iterate through the diagnosis accuracy functions to see which        // one should contain the probability needed        Enumeration daf_enum = diagnosis_accuracy_functions.elements();        while ( daf_enum.hasMoreElements() )         {            DiagnosisAccuracyFunction daf =                    (DiagnosisAccuracyFunction) daf_enum.nextElement();            /*             if (this._logger.isDebugEnabled())                 this._logger.debug                        ( "#### Diagnosis Acc Func -- asset state desc = "                           + daf.getAssetState().getStateName()                           + ", state descriptor value = "                           +  daf.getAssetStateValue().getName()                           + ", diagnosis name = "                           + daf.getDiagnosisStateValue().getName() );            */            // NOTE: This next 'if' predicate used to compare asset            // state descriptor objects rather than their String            // names.  I did not hunt it down, but this was causing a            // problem, and the string comparison seems to have fixed            // it.            //            if ( state_descriptor_name.equalsIgnoreCase                 ( daf.getAssetState().getStateName() )                  && state_descriptor_value.equalsIgnoreCase                 ( daf.getAssetStateValue().getName() )                  && search_name.equalsIgnoreCase                 ( daf.getDiagnosisStateValue().getName() ) )             {                found_prob = daf.getProbability();                found = true;                break;            }        } // end iteration over diagnosis accuracy functions        if ( ! found )        {            if (this._logger.isDebugEnabled())                 this._logger.debug                        ("getObsProb : No obs prob found in "                         + "diag acc func. Assuming zero." );        }        // Now we have to factor in fact that the OK diagnosis is not        // explicitly represented.         //        if ( diagnosis_name.equalsIgnoreCase( DIAGNOSIS_OK_STR ))        {            if (this._logger.isDebugEnabled())                 this._logger.debug("getObsProb : "                                   + "[indirect: (1-p)] : "                                    + "Pr( diag=" + diagnosis_name                                    + " | state="                                    + state_descriptor_value + ") = "                                   + "1.0 - " + found_prob );                        return 1.0 - found_prob;        }        else        {            if (this._logger.isDebugEnabled())                 this._logger.debug("getObsProb : "                                   + "[direct] : "                                    + "Pr( diag=" + diagnosis_name                                    + " | state="                                    + state_descriptor_value + ") = "                                   + found_prob );             return found_prob;        }    }