Scripts for building an Alloy benchmark workflow:
- collect candidate Alloy models,
- filter for compatibility,
- generate English descriptions,
- generate model instances.
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install openai ollamaThis repository expects your OpenAI key in:
./secret/key
Create the file and paste only the raw key value into it (no quotes/newlines beyond the final newline).
Two Java versions are used:
- Java 17 for
alloy-diff.jar - Java 8 for
CompoSAT.jar
These scripts require explicit environment variables:
- JAVA_HOME_17
- JAVA_HOME_8
Run these commands in your shell before running filter/instance scripts:
export JAVA_HOME_17="/path/to/jdk-17"
export JAVA_HOME_8="/path/to/jdk-8"Verify both are set and correct:
echo "$JAVA_HOME_17"
"$JAVA_HOME_17/bin/java" -version
echo "$JAVA_HOME_8"
"$JAVA_HOME_8/bin/java" -versionExpected major versions:
- JAVA_HOME_17/bin/java reports 17
- JAVA_HOME_8/bin/java reports 1.8 (or 8)
Use this location for your input Alloy models:
./validModels/models/
You can keep nested folders; scripts recurse through subdirectories.
Filter models before generation:
./validModels/checkValidity.sh ./validModels/modelsWhat this does:
- checks Alloy-diff compatibility (Java 17)
- checks CompoSAT compatibility (Java 8)
- copies passing models into:
./validModels/validModels/
Create a folder called benchmark in the root directory. Copy all models you wish to use into benchmark/models.
Run the following command to generate descriptions:
python ./scripts/master.py openAI ./benchmark/models ./benchmark/descriptionsThis traverses all .als files recursively and writes one .md description per model.
./scripts/generate-instances.sh ./benchmark/models ./benchmark/instances 120 4Arguments:
- input
.alsfile or directory - output directory
- time limit in seconds per model (default
120) - max parallel jobs in directory mode (default
4)
This step uses scripts/InstanceGenerator.java and runs exact scopes for top-level signatures.
Default command (uses x=10, y=5):
./scripts/generate-general-instances.shExplicit command (same defaults shown):
./scripts/generate-general-instances.sh ./benchmark/models ./benchmark/generalInstances 10 5Arguments:
- models directory (default
./benchmark/models) - output directory (default
./benchmark/generalInstances) x: max instances kept per scope (default10)y: max scope, runs1..y(default5)- timeout in seconds per model/scope run (optional, default
45)
Notes:
- Traverses all
.alsfiles recursively under the models directory. - For each model and each scope from
1toy, keeps up toxxml instances. - If fewer than
xsatisfiable instances exist at a scope, it keeps however many exist. - Output layout is:
benchmark/generalInstances/<model-relative-path>/scope_<n>/. - Random selection uses a larger candidate pool per scope, then samples down to
x. - Candidate pool size defaults to
3*x; override withCANDIDATE_MULTIPLIER.