public GraphicalModel compileModel() {
    GraphicalModel compiled = new GraphicalModel();
    for (GraphicalModel.Factor factor : model.factors) {
      compiled.addStaticFactor(factor.neigborIndices, factor.getDimensions(),
          assign -> factor.getAssignmentValue(assign, weights));
    }

    // Add any metadata
    for (int var = 0; var < model.numVariables(); ++var) {
      Map<String, String> metadata = model.getVariableMetaDataByReference(var);
      if (metadata.containsKey(VARIABLE_OBSERVED_VALUE)) {
        compiled.getVariableMetaDataByReference(var).put(VARIABLE_OBSERVED_VALUE, metadata.get(VARIABLE_OBSERVED_VALUE));
      }
    }
    return compiled;
  }
public GraphicalModel compileModel ( ) { GraphicalModel compiled = new GraphicalModel ( ) ; for ( GraphicalModel . Factor factor : model . factors ) { compiled . addStaticFactor ( factor . neigborIndices , factor . getDimensions ( ) , assign -> factor . getAssignmentValue ( assign , weights ) ) ; } for ( int var = 0 ; var < model . numVariables ( ) ; ++ var ) { Map < String , String > metadata = model . getVariableMetaDataByReference ( var ) ; if ( metadata . containsKey ( VARIABLE_OBSERVED_VALUE ) ) { compiled . getVariableMetaDataByReference ( var ) . put ( VARIABLE_OBSERVED_VALUE , metadata . get ( VARIABLE_OBSERVED_VALUE ) ) ; } } return compiled ; }
Compile this model into a static model, given the model and weights in this
clique tree.

@return A graphical model which is composed entirely of static (i.e.,
not featurized) factors.