Public Member Functions | |
void | convertFormula (WeightedFormula wf, MarkovRandomField mrf) throws Exception |
void | onGroundedFormula (WeightedFormula wf, MarkovRandomField mrf) throws Exception |
void | run (String wcspFilename, String scenarioSettingsFilename) throws FileNotFoundException |
void | setGroundAtomState (PossibleWorld w, int wcspVarIdx, int domIdx) |
WCSPConverter (MarkovRandomField mrf) throws Exception | |
WCSPConverter (String mlnFileLoc, String dbFileLoc) throws Exception | |
Protected Member Functions | |
void | atom2func (GroundAtom gnd) |
void | atom2var () |
void | convertFormula (Formula f, ArrayList< Integer > wcspVarIndices, int i, PossibleWorld w, int[] g, double weight, ArrayList< String > settingsZero, ArrayList< String > settingsOther) throws Exception |
void | convertFormula (WeightedFormula wf) throws Exception |
void | generateHead (PrintStream out) |
void | setBlockState (PossibleWorld w, HashSet< GroundAtom > block, String value) |
Protected Attributes | |
Double | deltaMin |
HashMap< String, HashSet < String > > | doms |
HashMap< String, String > | func_dom |
HashMap< Integer, Integer > | gnd_sfvaridx |
HashMap< GroundAtom, Integer > | gnd_varidx |
HashMap< Integer, Integer > | gndID_BlockID |
boolean | initialized = false |
MarkovLogicNetwork | mln |
int | numConstraints = 0 |
PrintStream | ps |
StringBuffer | sb_result |
StringBuffer | sb_settings |
HashMap< Integer, HashSet < GroundAtom > > | sfvars_gnd |
HashMap< Integer, Integer > | sfvars_vars |
ArrayList< String > | simplifiedVars |
long | sumSoftCosts = 0 |
ArrayList< String > | vars |
HashMap< String, HashSet < GroundAtom > > | vars_gnd |
PossibleWorld | wld |
Private Member Functions | |
StringBuffer | saveSzenarioSettings (StringBuffer sb) |
void | simplyfyVars (ArrayList< String > variables, Database db) throws Exception |
Converts an instantiated MLN (i.e. a ground MRF) into the Toulbar2 WCSP format
Definition at line 31 of file WCSPConverter.java.
edu::tum::cs::wcsp::WCSPConverter::WCSPConverter | ( | String | mlnFileLoc, | |
String | dbFileLoc | |||
) | throws Exception [inline] |
Note: This constructor is more memory-efficient as does not require the whole set of ground formulas to be materialized in an MRF
mlnFileLoc | MLN file | |
dbFileLoc | MLN database file |
Exception |
Definition at line 61 of file WCSPConverter.java.
edu::tum::cs::wcsp::WCSPConverter::WCSPConverter | ( | MarkovRandomField | mrf | ) | throws Exception [inline] |
void edu::tum::cs::wcsp::WCSPConverter::atom2func | ( | GroundAtom | gnd | ) | [inline, protected] |
this method checks whether a variable for a groundatom already exists; if a block exists, groundatom is added to this blockvariable, otherwise a new blockvariable will be created
gnd | groundatom to check for existing blockvariable |
Definition at line 188 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::atom2var | ( | ) | [inline, protected] |
this method generates a variable for each groundatom; for blocks only one variable is created
Definition at line 158 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::convertFormula | ( | WeightedFormula | wf, | |
MarkovRandomField | mrf | |||
) | throws Exception [inline] |
Definition at line 444 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::convertFormula | ( | Formula | f, | |
ArrayList< Integer > | wcspVarIndices, | |||
int | i, | |||
PossibleWorld | w, | |||
int[] | g, | |||
double | weight, | |||
ArrayList< String > | settingsZero, | |||
ArrayList< String > | settingsOther | |||
) | throws Exception [inline, protected] |
recursive method to generate all possibilities for a formula
f | formula (for this formula all possiblilities are generated) | |
wcspVarIndices | set of all groundatoms of the formula | |
i | counter to terminate the recursion | |
w | possible world to evaluate costs for a setting of groundatoms | |
g | array to save the current allocation of the variable | |
weight | weight of the formula to calculate costs | |
settingsZero | set to save all possibilities with costs of 0 | |
settingsOther | set to save all possibilities with costs different to 0 |
Exception |
Definition at line 357 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::convertFormula | ( | WeightedFormula | wf | ) | throws Exception [inline, protected] |
this method generates a WCSP-Constraint for a formula
f | formula (for this formula a WCSP- constraint is generated), the formula is already simplified | |
weight | the weight of the formula to calculate the costs |
Exception |
Definition at line 262 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::generateHead | ( | PrintStream | out | ) | [inline, protected] |
writes the header of the WCSP file
out | the stream to write to |
Definition at line 324 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::onGroundedFormula | ( | WeightedFormula | wf, | |
MarkovRandomField | mrf | |||
) | throws Exception [inline] |
this method is the callback-method of the ground_and_simplify method; it generates a WCSP-Constraint for the given formula
f | a ground formula | |
weight | the weight of the formula | |
db | evidence of the scenario |
Exception |
Implements edu::tum::cs::srl::mln::GroundingCallback.
Definition at line 440 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::run | ( | String | wcspFilename, | |
String | scenarioSettingsFilename | |||
) | throws FileNotFoundException [inline] |
performs the conversion of the ground MRF to the WCSP file
wcspFilename | ||
scenarioSettingsFilename | (may be null) |
FileNotFoundException |
Definition at line 89 of file WCSPConverter.java.
StringBuffer edu::tum::cs::wcsp::WCSPConverter::saveSzenarioSettings | ( | StringBuffer | sb | ) | [inline, private] |
this method saves all required mappings and variables in a file to restore the szenario and display the solution
sb | StringBuffer to save the settings of the szenario |
Definition at line 114 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::setBlockState | ( | PossibleWorld | w, | |
HashSet< GroundAtom > | block, | |||
String | value | |||
) | [inline, protected] |
this method sets the truth values of a block of mutually exclusive ground atoms
block | atoms within the block | |
value | value indicating the atom to set to true TODO this method makes evil assumptions about the blocking of variables |
Definition at line 416 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::setGroundAtomState | ( | PossibleWorld | w, | |
int | wcspVarIdx, | |||
int | domIdx | |||
) | [inline] |
sets the state of the ground atoms in w that correspond to the given wcsp variable
w | ||
wcspVarIdx | ||
domIdx | index into the wcsp variable's domain |
Definition at line 398 of file WCSPConverter.java.
void edu::tum::cs::wcsp::WCSPConverter::simplyfyVars | ( | ArrayList< String > | variables, | |
Database | db | |||
) | throws Exception [inline, private] |
this method simplifies the generated variables (if a variable is given by the evidence, it's not necessary for the WCSP)
variables | all generated variables to check for evidence-entry | |
db | evidence of the szenario |
Exception |
Definition at line 222 of file WCSPConverter.java.
Double edu::tum::cs::wcsp::WCSPConverter::deltaMin [protected] |
Definition at line 35 of file WCSPConverter.java.
HashMap<String, HashSet<String> > edu::tum::cs::wcsp::WCSPConverter::doms [protected] |
Definition at line 36 of file WCSPConverter.java.
HashMap<String, String> edu::tum::cs::wcsp::WCSPConverter::func_dom [protected] |
Definition at line 47 of file WCSPConverter.java.
HashMap<Integer, Integer> edu::tum::cs::wcsp::WCSPConverter::gnd_sfvaridx [protected] |
Definition at line 41 of file WCSPConverter.java.
HashMap<GroundAtom, Integer> edu::tum::cs::wcsp::WCSPConverter::gnd_varidx [protected] |
Definition at line 40 of file WCSPConverter.java.
HashMap<Integer, Integer> edu::tum::cs::wcsp::WCSPConverter::gndID_BlockID [protected] |
Definition at line 37 of file WCSPConverter.java.
boolean edu::tum::cs::wcsp::WCSPConverter::initialized = false [protected] |
Definition at line 52 of file WCSPConverter.java.
Definition at line 33 of file WCSPConverter.java.
int edu::tum::cs::wcsp::WCSPConverter::numConstraints = 0 [protected] |
Definition at line 51 of file WCSPConverter.java.
PrintStream edu::tum::cs::wcsp::WCSPConverter::ps [protected] |
Definition at line 50 of file WCSPConverter.java.
StringBuffer edu::tum::cs::wcsp::WCSPConverter::sb_result [protected] |
Definition at line 49 of file WCSPConverter.java.
StringBuffer edu::tum::cs::wcsp::WCSPConverter::sb_settings [protected] |
Definition at line 49 of file WCSPConverter.java.
HashMap<Integer, HashSet<GroundAtom> > edu::tum::cs::wcsp::WCSPConverter::sfvars_gnd [protected] |
maps indices of simplified WCSP variables to sets of ground atoms
Definition at line 46 of file WCSPConverter.java.
HashMap<Integer, Integer> edu::tum::cs::wcsp::WCSPConverter::sfvars_vars [protected] |
Definition at line 48 of file WCSPConverter.java.
ArrayList<String> edu::tum::cs::wcsp::WCSPConverter::simplifiedVars [protected] |
Definition at line 39 of file WCSPConverter.java.
long edu::tum::cs::wcsp::WCSPConverter::sumSoftCosts = 0 [protected] |
Definition at line 53 of file WCSPConverter.java.
ArrayList<String> edu::tum::cs::wcsp::WCSPConverter::vars [protected] |
Definition at line 38 of file WCSPConverter.java.
HashMap<String, HashSet<GroundAtom> > edu::tum::cs::wcsp::WCSPConverter::vars_gnd [protected] |
Definition at line 42 of file WCSPConverter.java.
PossibleWorld edu::tum::cs::wcsp::WCSPConverter::wld [protected] |
Definition at line 34 of file WCSPConverter.java.