BLOGBuilder is a module of ComPI that allows the automatic creation of series of BLOG model files that ideally increase in complexity. In this regard, multiple World Filling Strategies (as we call them) are available as explained below. It is also possible to implement custom strategies for the creation of models and model series.
Due to the not (yet) final state of BLOGBuilder, it is not yet distributed as a executable jar file. To allow the greatest amount of flexibility possible, it is shipped as the raw Java files. In order to create series of model files, it is recommended you setup a Java project (e.g., in the Eclipse IDE) and proceed as follows.
Strategy and parameter selection happen directly by setting corresponding variables in the java files:
The main
method contains the selection of a WorldCreationStrategy
in the following lines:
// ...
//WorldCreationStrategy strat = new RandomSampleStrategy();
WorldCreationStrategy strat = new RandVarOccAugmStrategy();
//WorldCreationStrategy strat = new LogVarAugmentationStrategy();
//WorldCreationStrategy strat = new RandVarAugmentationStrategy();
//WorldCreationStrategy strat = new FactorAugmentationStrategy();
//WorldCreationStrategy strat = new IncByWorldStrategy();
//WorldCreationStrategy strat = new ParallelFactorArgsAugmentationStrategy();
//WorldCreationStrategy strat = new IncDegreeStrategy();
// ...
Select a strategy by including the corresponding line (removing the //
at the beginning of the line) and commenting out all remaining strategies (putting //
at the beginning of the lines).
The parameters describing the models to be created are then specified in the .java
file corresponding to the chosen strategy. For the code snippet from above (where the LogVarAugmentationStrategy
is selected), we would have to check out RandVarAugmentationStrategy.java
.
In that file, the corresponding variables params_*
are set, e.g. specifying the number of logvars, randvars, factors, the maximum number of arguments for a randvar or factor, etc.
// ...
// Do you want to create all queries or 1 query per randvar?
private boolean allQueries = true;
// How big should each of the domains be?
private int[] domainSizes = {10,100,1000};
// How often do you want each size to be created (=multiple independent runs)?
int rerollCount = 3;
// Should (old) RandVars from factors be replaced or should the factors be augmented?
boolean replaceRandVars = false;
int[] params_randVarCounts = {3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20};
// We go through these counts in parallel
int[] params_logVarCounts = {3};
int[] params_factorCounts = {5};
// We go through these counts as power set (all combinations)
int[] params_maxRandVarArgs = {2, 3};
int[] params_argsInFactor = {4, 5};
int[] params_maxRandVarOcc = {2, 3};
// ...
The logic describing how these parameters are processed is then described in the paramHandler*()
method. You will need to follow the structure of the nested for loops to derive said logic, e.g., which variable sets are simply iterated 'in parallel', or which variable sets are processed as cartesian product.
In order to start the model creation process, we have to build it first. You can either do this with your command line and Maven, which you need to have correctly set up, or do it directly from Eclipse (recommended). After running it, the BLOG model files are outputted to a out/
subdirectory that is created for you, along with two reports describing the model creation process.
Import the source files as a Maven project to Eclipse (File -> Import -> Maven / Existing Maven Project -> Select the pom.xml -> Finish), set up a run configuration with the blogbuilder.Main
class containing the main method (if needed, default might be fine) and just run the thing using the run button (play button in the menu bar).
-
Build a jar file using (from the parent BLOGBuilder directory):
$ mvn compile $ mvn clean compile assembly:single
-
Execute said jar file (it is located in the
target
subdirectory):$ java -jar target/BLOGBuilder-0.0.1-SNAPSHOT-with-dependencies.jar
There are two key class types needed for extending BLOGBuilder with a custom logic on how models are created:
*Factories
contain the actual creation of elements (logvars, randvars, parfactors, ...) in the models, based on the specification of parameters (e.g., number of logvars/randvars/parfactors, ...).*Strategies
can be seen as model creation control units: They contain the setting of parameters, accordingly creating worlds and calling the factories' methods to populate said worlds.
Followingly, the already implemented strategies and factories are listed and shortly explained.
Strategies are implemented as sub-classes of the abstract super class WorldCreationStrategy
. For the strategies, the underlying key ideas will be outlined. To reconstruct the exact logic of world creation, look at the factory descriptions below.
RandomSampleStrategy
: Create a world with a specified number of randomly created objects, that are in random relations. Mostly used for the generation of base worlds.LogVarAugmentationStrategy
: Augment a given base world by adding LogVars.RandVarAugmentationStrategy
: Augment a given base world by adding RandVars.FactorAugmentationStrategy
: Augment a given base world by adding parfactors.ParallelFactorArgsAugmentationStrategy
: Augment a given base world by increasing the number of arguments for the existing factors (in parallel for all factors).IncByWorldStrategy
: Augment a given base world by duplicating and connecting initial base world with duplicate.RandVarOccAugmStrategy
: Augment a given base world by increasing the number of times the randvars occur as arguments for the parfactors.IncDegreeStrategy
: Similar to IncByWorldStrategy but duplicates are all connected to a single randvar in the base world, leading to a star topology of the model graph.
Explanation: baseFactory
vs. augmentationFactory
We differentiate between two factory types:
- A
baseFactory
is able to fill a world with elements from scratch (e.g. theRandomSampleFactory
) - creating abaseWorld
, whereas - a
augmentationFactory
takes an existingbaseWorld
and augments it by changing (adding, removing, switching, ...) its elements, thus creating aaugmentWorld.
When new elements are added, theaF
should request the world'sbaseFactory
in order for the added elements' creation to comply with the previous world filling strategy.
insertLogVars(...)
-Strategy:
- Create
logVarCount
LogVars named according to the world's naming function.
insertRandVars(...)
-Strategy:
- Create
randVarCount
RandVars. - For each RandVar:
- Pick a random
argCount
between 0 andmaxRandVarArgs
- Shuffle the LogVars and pick the
argCount
first elements as arguments for the current RandVar.
- Pick a random
insertFactors(...)
-Strategy:
- Create
factorCount
factors with a randomly pickedargCount
between 1 andfactorArgCount
.
Only considers RandVars that are not yet connected (i.e. occur together with one of the current arg RandVars from this Factor). Might lead to smaller arg turnout thanargCount
. In that case a warning is displayed in the console. Args are filled with the following priority.- RandVars without occurrence
- RandVars not yet at
maxOccurrence
- RandVars at
maxOccurrence
extends RandomSampleFactory
insertFactors(...)
-Strategy:
- Create base world with
l
LogVars,r
RandVars - Factor creation:
- Create
r-1
factors, one for each of the lastr-1
RandVars. - The
0
th RandVar is added to every factor (to connect all factors).
- Create
Augmentation Factories all extend the abstract class GenericAugmentationFactory
where some default behaviors are implemented (e.g. the init*
methods, where all elements from a base world are copied).
insertLogVars(...)
-Strategy:
- Clone existing LogVars from base world.
- Add new LogVars based on the base world's filling strategy.
- Candidate RandVars are those with at at least 1 argument LogVar.
- Randomly choose
rv_count
RandVars from the existing candidates, withrv_count
as a random number between1
and the world'smaxLVOccurence
. - For each of these RandVars, randomly replace one of their current LogVars
insertRandVars(...)
-Strategy:
- Clone existing RandVars from base world.
- Add new RandVars based on the base world's filling strategy.
- Factors with at least one RandVar with an occurence > 1 are candidates. If none such candidate exists, all factors with at least 1 argument RandVar are taken.
- Randomly choose
fac_count
(par)factors from the candidates, withfac_count
as a random number between1
and the world'smaxRVOccurence
. - For each of these (par)factors, randomly replace one of the current RandVars.
insertFactors(...)
-Strategy:
- Clone existing (par)factors from base world.
- Add new (par)factors based on the base world's base filling strategy.
insertFactors(...)
-Strategy:
- Copy all factors from the base world to the new world
w
. - For each factor: Based on certain probability (e.g. 50%):
- Add a randomly chosen RandVar to those factors.
augmentation
strategy:
- Copy all factors from base world to the new world w.
- For each factor, create a new RandVar and take it into its arguments.