Search in sources :

Example 6 with HOGModel

use of com.sri.ai.praise.core.representation.classbased.hogm.HOGModel in project aic-praise by aic-sri-international.

the class HOGMModelParsing method parseNonEmptyModelString.

private HOGModel parseNonEmptyModelString(String nonEmptyModelString) {
    HOGMParserWrapper parser = new HOGMParserWrapper();
    HOGModel model = parser.parseModel(nonEmptyModelString, makeParserErrorListener());
    parser.close();
    return model;
}
Also used : HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel) HOGMParserWrapper(com.sri.ai.praise.core.representation.classbased.hogm.parsing.HOGMParserWrapper)

Example 7 with HOGModel

use of com.sri.ai.praise.core.representation.classbased.hogm.HOGModel in project aic-praise by aic-sri-international.

the class HOGMModelParsing method parse.

private HOGModel parse(String modelString) {
    HOGModel model;
    if (isNullOrEmptyString(modelString)) {
        model = null;
        collectEmptyModelStringError();
    } else {
        model = parseNonEmptyModelString(modelString);
    }
    return model;
}
Also used : HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel)

Example 8 with HOGModel

use of com.sri.ai.praise.core.representation.classbased.hogm.HOGModel in project aic-praise by aic-sri-international.

the class UtilTest method main.

/**
 * Test if conversion between String model and ExpressionBasedModel is working.
 */
public static void main(String[] args) {
    String modelString = "random earthquake: Boolean;\n" + "random burglary: Boolean;\n" + "random alarm: Boolean;\n" + "earthquake 0.01;\n" + "burglary 0.1;\n" + "if earthquake\n" + "then if burglary\n" + "then alarm 0.95\n" + "else alarm 0.6\n" + "else if burglary\n" + "then alarm 0.9\n" + "else alarm 0.01;\n";
    List<HOGMProblemError> modelErrors = new ArrayList<>();
    HOGModel hogModel = parseModelStringToHOGMModel(modelString, modelErrors);
    ExpressionBasedModel expressionBasedModel = parseHOGModelToExpressionBasedModel(hogModel);
    System.out.println(expressionBasedModel.toString() + "\n");
    ExpressionBasedModelToFeatureBasedModelTranslation translation = new ExpressionBasedModelToFeatureBasedModelTranslation(expressionBasedModel, new LinkedList<>());
    System.out.println("translation : " + translation.featureBasedModel.toString());
}
Also used : HOGMProblemError(com.sri.ai.praise.core.inference.byinputrepresentation.classbased.hogm.parsing.HOGMProblemError) HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel) ExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel) UsefulOperationsParameterEstimation.parseHOGModelToExpressionBasedModel(com.sri.ai.praise.learning.symbolicparameterestimation.util.UsefulOperationsParameterEstimation.parseHOGModelToExpressionBasedModel) ArrayList(java.util.ArrayList) ExpressionBasedModelToFeatureBasedModelTranslation(com.sri.ai.praise.core.representation.classbased.featurebased.ExpressionBasedModelToFeatureBasedModelTranslation)

Example 9 with HOGModel

use of com.sri.ai.praise.core.representation.classbased.hogm.HOGModel in project aic-praise by aic-sri-international.

the class ParameterEstimationForHOGModelTest method testHOGMBased.

// TODO: not matching original expected result put in by Sarah
// @Test
public void testHOGMBased() {
    String modelString = "random terrorAttacks : 0..20;\n" + "random newJobs : 0..100000;\n" + "random dow: 11000..18000;\n" + "random economyIsPoor : Boolean;\n" + "random economyIsGreat : Boolean;\n" + "random attackPerception: Boolean;\n" + "random likeIncumbent  : 0..100000000;\n" + "random likeChallenger : 0..100000000;\n" + "constant Alpha: Real;\n" + "economyIsPoor <=> dow < 13000 and newJobs < 30000;\n" + "economyIsGreat <=> dow > 16000 and newJobs > 70000;\n" + "attackPerception <=> terrorAttacks > 4;\n" + "if economyIsGreat\n" + "then if likeIncumbent > 70000000 then Alpha/30000000 else (1-Alpha)/(70000000 + 1)\n" + "else if economyIsPoor\n" + "then if likeIncumbent < 40000000 then 0.8/40000000 else 0.2/(60000000 + 1)\n" + "else if attackPerception\n" + "then if likeIncumbent < 60000000 then 0.9/60000000 else 0.1/(40000000 + 1);\n";
    List<HOGMProblemError> modelErrors = new ArrayList<>();
    List<Pair<Expression, Expression>> pairsQueryEvidence = new LinkedList<Pair<Expression, Expression>>();
    Pair<Expression, Expression> pair = new Pair<Expression, Expression>(parse("likeIncumbent > likeChallenger"), parse("null"));
    pairsQueryEvidence.add(pair);
    ParameterEstimationForHOGModel parameterEstimationForHOGModel = new ParameterEstimationForHOGModel(modelString, pairsQueryEvidence, modelErrors);
    HashMap<Expression, Double> expected = new HashMap<Expression, Double>();
    expected.put(parse("Alpha"), 1.0);
    HashMap<Expression, Double> mapResult = runTestHOGModelBased(expected, parameterEstimationForHOGModel, new double[] { 0 });
    HOGModel test = parameterEstimationForHOGModel.buildOptimizedHOGModel(mapResult);
    ExpressionBasedModel newModel = parseHOGModelToExpressionBasedModel(test);
    System.out.println(newModel.toString());
    assertEquals(expected, mapResult);
}
Also used : ParameterEstimationForHOGModel(com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForHOGModel) HashMap(java.util.HashMap) ExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel) UsefulOperationsParameterEstimation.parseHOGModelToExpressionBasedModel(com.sri.ai.praise.learning.symbolicparameterestimation.util.UsefulOperationsParameterEstimation.parseHOGModelToExpressionBasedModel) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) HOGMProblemError(com.sri.ai.praise.core.inference.byinputrepresentation.classbased.hogm.parsing.HOGMProblemError) ParameterEstimationForHOGModel(com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForHOGModel) HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel) Expression(com.sri.ai.expresso.api.Expression) Pair(com.sri.ai.util.base.Pair)

Example 10 with HOGModel

use of com.sri.ai.praise.core.representation.classbased.hogm.HOGModel in project aic-praise by aic-sri-international.

the class HOGModelGroundingTest method test.

/**
 * @throws AssertionError
 */
@Test
public void test() throws AssertionError {
    long start = System.currentTimeMillis();
    StringJoiner sj = new StringJoiner("\n");
    sj.add("sort People : 10, Putin;");
    sj.add("sort Countries : 10, USA, Russia;");
    sj.add("random country : Countries;");
    sj.add("random president : People;");
    sj.add("random communism : Boolean;");
    sj.add("random democracy : Boolean;");
    sj.add("random votePutin : 1..15;");
    sj.add("if country = Russia then if president = Putin then communism else not communism else if democracy then not communism else communism;");
    sj.add("if country = Russia then if votePutin > 5 then president = Putin else not president = Putin;");
    HOGMParserWrapper parser = new HOGMParserWrapper();
    HOGModel parsedModel = parser.parseModel(sj.toString());
    ExpressionBasedModel factorsAndTypes = new HOGMExpressionBasedModel(parsedModel);
    List<Expression> evidence = new ArrayList<>();
    evidence.add(Expressions.parse("communism"));
    StringJoiner outputBuffer = new StringJoiner("");
    HOGModelGrounding.ground(factorsAndTypes, evidence, new // NOTE: an example listener that outputs in the UAI format
    HOGModelGrounding.Listener() {

        int numberVariables;

        StringJoiner preamble = new StringJoiner("");

        StringJoiner functionTables = new StringJoiner("");

        List<Pair<Integer, Integer>> evidence = new ArrayList<>();

        @Override
        public void numberGroundVariables(int number) {
            this.numberVariables = number;
            preamble.add("MARKOV\n");
            preamble.add("" + number + "\n");
        }

        @Override
        public void groundVariableCardinality(int variableIndex, int cardinality) {
            preamble.add("" + cardinality);
            if (variableIndex == (numberVariables - 1)) {
                preamble.add("\n");
            } else {
                preamble.add(" ");
            }
        }

        @Override
        public void numberFactors(int number) {
            preamble.add("" + number + "\n");
        }

        @Override
        public void factorParticipants(int factorIndex, int[] variableIndexes) {
            preamble.add("" + variableIndexes.length);
            for (int i = 0; i < variableIndexes.length; i++) {
                preamble.add(" " + variableIndexes[i]);
            }
            preamble.add("\n");
        }

        @Override
        public void factorValue(int numberFactorValues, boolean isFirstValue, boolean isLastValue, Rational value) {
            if (isFirstValue) {
                functionTables.add("\n" + numberFactorValues + "\n");
            } else {
                functionTables.add(" ");
            }
            functionTables.add("" + value.doubleValue());
            if (isLastValue) {
                functionTables.add("\n");
            }
        }

        @Override
        public void evidence(int variableIndex, int valueIndex) {
            evidence.add(new Pair<>(variableIndex, valueIndex));
        }

        @Override
        public void groundingComplete() {
            long end = System.currentTimeMillis() - start;
            outputBuffer.add("--- MODEL ---\n");
            outputBuffer.add(preamble.toString());
            outputBuffer.add(functionTables.toString());
            outputBuffer.add("--- EVIDENCE ---\n");
            outputBuffer.add("" + evidence.size());
            for (Pair<Integer, Integer> evidenceAssignment : evidence) {
                outputBuffer.add(" ");
                outputBuffer.add(evidenceAssignment.first.toString());
                outputBuffer.add(" ");
                outputBuffer.add(evidenceAssignment.second.toString());
            }
            System.out.println(outputBuffer.toString());
            System.out.println("\nTime taken for grounding (not printing): " + end + " ms.");
        }
    });
    String expected = "--- MODEL ---\n" + "MARKOV\n" + "5\n" + "10 10 2 2 15\n" + "2\n" + "4 0 1 2 3\n" + "3 0 4 1\n" + "\n" + "400\n" + "0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 0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.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5\n" + "--- EVIDENCE ---\n" + "1 2 1";
    assertEquals(expected, outputBuffer.toString());
}
Also used : Rational(com.sri.ai.util.math.Rational) HOGMExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.hogm.components.HOGMExpressionBasedModel) ExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel) ArrayList(java.util.ArrayList) HOGMParserWrapper(com.sri.ai.praise.core.representation.classbased.hogm.parsing.HOGMParserWrapper) HOGModelGrounding(com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.HOGModelGrounding) HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel) Expression(com.sri.ai.expresso.api.Expression) HOGMExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.hogm.components.HOGMExpressionBasedModel) StringJoiner(java.util.StringJoiner) Pair(com.sri.ai.util.base.Pair) Test(org.junit.Test)

Aggregations

HOGModel (com.sri.ai.praise.core.representation.classbased.hogm.HOGModel)14 ArrayList (java.util.ArrayList)9 ExpressionBasedModel (com.sri.ai.praise.core.representation.classbased.expressionbased.api.ExpressionBasedModel)8 HOGMProblemError (com.sri.ai.praise.core.inference.byinputrepresentation.classbased.hogm.parsing.HOGMProblemError)6 Expression (com.sri.ai.expresso.api.Expression)5 UsefulOperationsParameterEstimation.parseHOGModelToExpressionBasedModel (com.sri.ai.praise.learning.symbolicparameterestimation.util.UsefulOperationsParameterEstimation.parseHOGModelToExpressionBasedModel)5 HOGMParserWrapper (com.sri.ai.praise.core.representation.classbased.hogm.parsing.HOGMParserWrapper)4 DefaultExpressionBasedModel (com.sri.ai.praise.core.representation.classbased.expressionbased.core.DefaultExpressionBasedModel)3 HOGMExpressionBasedModel (com.sri.ai.praise.core.representation.classbased.hogm.components.HOGMExpressionBasedModel)3 Pair (com.sri.ai.util.base.Pair)2 HOGMModelParsing (com.sri.ai.praise.core.inference.byinputrepresentation.classbased.hogm.parsing.HOGMModelParsing)1 ExpressionBasedModelToFeatureBasedModelTranslation (com.sri.ai.praise.core.representation.classbased.featurebased.ExpressionBasedModelToFeatureBasedModelTranslation)1 TranslatorOptions (com.sri.ai.praise.core.representation.translation.ciaranframework.api.TranslatorOptions)1 HOGModelGrounding (com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.HOGModelGrounding)1 UAI_to_HOGMv1_Using_Equalities_Translator (com.sri.ai.praise.core.representation.translation.ciaranframework.core.uai.UAI_to_HOGMv1_Using_Equalities_Translator)1 ParameterEstimationForHOGModel (com.sri.ai.praise.learning.symbolicparameterestimation.ParameterEstimationForHOGModel)1 Rational (com.sri.ai.util.math.Rational)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1