Search in sources :

Example 11 with HOGModel

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

the class ExpressionBasedModelExamples method buildModel2.

public static ExpressionBasedModel buildModel2() {
    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<>();
    HOGModel hogmModel = parseModelStringToHOGMModel(modelString, modelErrors);
    ExpressionBasedModel expressionBasedModel = parseHOGModelToExpressionBasedModel(hogmModel);
    return expressionBasedModel;
}
Also used : HOGMProblemError(com.sri.ai.praise.core.inference.byinputrepresentation.classbased.hogm.parsing.HOGMProblemError) HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel) DefaultExpressionBasedModel(com.sri.ai.praise.core.representation.classbased.expressionbased.core.DefaultExpressionBasedModel) 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)

Example 12 with HOGModel

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

the class UsefulOperationsParameterEstimation method parseModelStringToHOGMModel.

/**
 * To convert a model String into a HOGModel.
 */
public static HOGModel parseModelStringToHOGMModel(String modelString, List<HOGMProblemError> modelErrors) {
    HOGMModelParsing parsingWithErrorCollecting = new HOGMModelParsing(modelString, modelErrors);
    HOGModel result = parsingWithErrorCollecting.getModel();
    return result;
}
Also used : HOGMModelParsing(com.sri.ai.praise.core.inference.byinputrepresentation.classbased.hogm.parsing.HOGMModelParsing) HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel)

Example 13 with HOGModel

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

the class ParameterEstimationForHOGModel method buildOptimizedHOGModel.

/**
 * Return the optimized HOGModel.
 */
public HOGModel buildOptimizedHOGModel(Map<Expression, Double> optimizedParameters) {
    String optimizedStringModel = buildOptimizedStringModel(optimizedParameters);
    HOGModel result = parseModelStringToHOGMModel(optimizedStringModel, this.modelErrors);
    return result;
}
Also used : HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel)

Example 14 with HOGModel

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

the class HOGMParserWrapper method parseModel.

public HOGModel parseModel(String string, Parser.ErrorListener errorListener) {
    Expression modelTupleExpression = parse(string, errorListener);
    HOGModel result = new HOGModel(string, modelTupleExpression);
    return result;
}
Also used : HOGModel(com.sri.ai.praise.core.representation.classbased.hogm.HOGModel) Expression(com.sri.ai.expresso.api.Expression)

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