Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
ef7c446
docs: added existing macc-discriminating run
vincepick Nov 8, 2024
2391358
build: updated clone command used to clone the repo
vincepick Jan 14, 2025
0b00d93
fix: updated dockerfile to fix incorrect vim install
vincepick Feb 12, 2025
909097b
Merge branch 'stacs-cp:main' into main
vincepick Feb 12, 2025
49bb7c4
fix: updated Dockerfile
vincepick Feb 16, 2025
f7461b6
refactor: wrapper changes for increased modularity, moving readsettin…
vincepick Feb 16, 2025
5cd5731
refactor: also moved read_args to another file
vincepick Feb 16, 2025
6be2fa9
revert: reverted the way of calling evaluate_essence...graded back to…
vincepick Feb 16, 2025
b064ec2
bug: added debug print statement for wrapper function
vincepick Feb 17, 2025
96c2f34
refactor: made the score constants global variables so will be consis…
vincepick Feb 18, 2025
ed57d41
test: running more testing with Conjures verbose output
vincepick Feb 25, 2025
d1d6a37
docs: adding sample outputs to show the issue with the current instan…
vincepick Feb 28, 2025
95237ed
test: added new test to testing pipeline for usage during development…
vincepick Mar 4, 2025
4a82d3c
test: added further testing capability
vincepick Mar 4, 2025
6bdf013
refactor: further moved items in for parameter handling of evaluate_e…
vincepick Mar 10, 2025
b3cad06
docs: added a comment to see the contents of settings for call_conure…
vincepick Mar 11, 2025
507edbe
feat: more progress on implementing the essence graded instance gener…
vincepick Mar 12, 2025
a1c90f3
feat: tore down and rebuilt full evaluate_essence_instance_graded fun…
vincepick Mar 26, 2025
c240409
test: updated runs for conjure with sat and optimisation problems
vincepick Mar 26, 2025
2f7e50c
fix: updated incorrect dictionary update
vincepick Mar 26, 2025
09ebf67
fix: updated essence_pipeline_utils to take correct number of argumen…
vincepick Mar 26, 2025
4fe5235
fix: updated incorrect accessing of a dictionary in call conjure solve
vincepick Mar 26, 2025
11f4e01
fix: incorrect dictionary access
vincepick Mar 26, 2025
693a243
feat: seemingly functional vessel_loading and simple runs
vincepick Mar 26, 2025
478b0f2
docs: updated readme with commands to set up experiments for essence …
vincepick Mar 26, 2025
a13a9a8
test: testing weather new approach to identifying a problem type works
vincepick Mar 27, 2025
ed6ec6e
feat: updated get_essence_problem_type function using Conjures pretty…
vincepick Mar 27, 2025
14c1b5f
test: adding results after getting nevaluations working
vincepick Apr 9, 2025
e7faff5
feat: added support for OR-tools in the essence pipeline
vincepick Apr 9, 2025
9c33982
test: adding print lines for testing scenario.r
vincepick Apr 10, 2025
e51ea96
test: experimenting with existing repair model for car_sequencing
vincepick Apr 10, 2025
aaf398b
test: further testing, current issue is data.table not being installe…
vincepick Apr 10, 2025
773dc8f
fix: updated scripts for functioning car-sequencing
vincepick Apr 10, 2025
67937da
fix: updated install-irace script
vincepick Apr 10, 2025
c5cb3bb
test: added succesful car_sequencing run to git
vincepick Apr 10, 2025
9ac03c1
fix: cleanup no longer used dependencies, data.table
vincepick Apr 10, 2025
862005c
data: updated data for using or-tools with an essence model
vincepick Apr 10, 2025
d5bda6c
data: initial run using car sequencing with new repair model
vincepick Apr 10, 2025
b2c17ec
Merge pull request #1 from vincepick/feat/teardown_essence
vincepick Apr 10, 2025
51e30f5
test: adding testing lines for discriminating
vincepick Apr 13, 2025
d131f08
test: more testing results for car_sequencing, seems to be a bug with…
vincepick Apr 14, 2025
58fbafd
test: adding debug statements for why there is no cutoff in solver ru…
vincepick Apr 15, 2025
93a0d22
fix: fixed incorrect paramter handling for maxsolvertime
vincepick Apr 15, 2025
e77b9eb
Merge pull request #2 from vincepick/feat/teardown_essence
vincepick Apr 15, 2025
7f65be5
fix: eliminated duplciate dependencies in scenario.R
vincepick Apr 10, 2025
52d693a
fix: installiRace
vincepick Apr 16, 2025
726b55d
fix: re added packages.r for irace install
vincepick Apr 16, 2025
9cae3f2
fix: car_sequencing issue, now working again with time limit
vincepick Apr 16, 2025
0941b3e
data: thorough car_sequencing data
vincepick Apr 16, 2025
7d717d5
feat: updated parameter handling, including adding the SR as a parser…
vincepick Apr 16, 2025
b483fcf
test: testing first run of discriminating instance generation post te…
vincepick Apr 21, 2025
25d029b
fix: further updates for generating discriminating instances
vincepick Apr 21, 2025
052e053
test: adding further debug comments
vincepick Apr 23, 2025
919ec0e
feat: updates to wrapper for discrim, successful setup, additional docs
vincepick Apr 29, 2025
e8451a1
adding sample output
vincepick Apr 29, 2025
6285c0b
feat: seemingly working discriminating instnace generation
vincepick Apr 29, 2025
7f321dc
pre another big refactor
vincepick Apr 29, 2025
b83b89f
refactor: broke wrapper into seperate files, still patching discrimin…
vincepick Apr 30, 2025
41d4ec7
example of funcitoning mzn
vincepick Apr 30, 2025
8ce97de
feat: debug comments and new essence discriminating pipeline updates
vincepick Apr 30, 2025
54300a9
feat: hopefully fully working discrimin instanec generation for essence
vincepick May 1, 2025
261cd66
feat: updated essence pipeline utils for discriminating instance gene…
vincepick May 1, 2025
57e8ef0
feat: updated collect_results for use with essnece pipeline, may requ…
vincepick May 3, 2025
16624c6
feat: finalized collect_results for essence, just needs further docum…
vincepick May 4, 2025
0e898f4
docs: additional commenting for discrim instance generation
vincepick May 7, 2025
27a4cce
feat: added additional repairModel parameter
vincepick May 7, 2025
2983eef
test: added testing for discriminating instance generation using Essence
vincepick May 7, 2025
da6ac4f
test: update to testing pipeline for hwich branches to target
vincepick May 7, 2025
688ee58
fix: update testing workflow
vincepick May 7, 2025
9a153c5
fix: testing workflow
vincepick May 7, 2025
c3cc0ff
fix: updated target branch name
vincepick May 7, 2025
aed72d1
fix: updated test workflows
vincepick May 7, 2025
d1a8c87
fix: update test sworkflow
vincepick May 7, 2025
62339ca
fix: update tests workflow, updating discrim tests
vincepick May 7, 2025
83a3497
fix: update to pr_discrim_tests
vincepick May 7, 2025
5b7e57a
fix: command line parameters
vincepick May 7, 2025
33458f2
fix: update scripts for testing workflow
vincepick May 7, 2025
43c016a
fix: update pr_discrim_tests
vincepick May 7, 2025
83a898d
fix: updated test scripts
vincepick May 7, 2025
053833a
fix: update test workflow
vincepick May 7, 2025
6603489
test: adding pr_discrim_tests
vincepick May 7, 2025
1359ff6
fix: update_test scripts
vincepick May 7, 2025
ee38d01
fix: github workflow
vincepick May 7, 2025
fe5b379
fix: update test workflow
vincepick May 7, 2025
ebf1e87
fix: update test workflow
vincepick May 7, 2025
5ef94bb
fix: update test flow
vincepick May 7, 2025
0b21571
fix: update test flow, lowering upper bounds so will run faster
vincepick May 7, 2025
1fec1ed
fixed: now passing test pipeline, and updated removed some unecessary…
vincepick May 7, 2025
c4210a8
fix: update push test yml
vincepick May 8, 2025
382d58d
fix: update push test yml
vincepick May 8, 2025
6560a4a
test: update test file
vincepick May 8, 2025
569c161
test: update test file
vincepick May 8, 2025
c965e1b
Merge pull request #4 from vincepick/feat/teardown_discrim
vincepick May 8, 2025
00ce3ed
fix: update Dockerfile
vincepick May 8, 2025
46e4486
fix: remove testing file
vincepick May 8, 2025
676f8de
fix: deleted temporary file prior to submission
vincepick May 8, 2025
2710117
data: added example data for both gradedand discriminating instance g…
vincepick May 8, 2025
32e2350
Merge pull request #5 from vincepick/feat/teardown_discrim
vincepick May 9, 2025
cef865c
docs: update docs and move submission outputs to other directory
vincepick May 9, 2025
c6e8a5a
Merge pull request #6 from vincepick/feat/teardown_discrim
vincepick May 9, 2025
98427fc
deleted experiments directory or easier to read PR
vincepick May 9, 2025
8cdefa0
deleted sample_outputs to make PR easier to read
vincepick May 9, 2025
e03c049
docs: updated comments
vincepick May 9, 2025
94a14e0
docs: removed pycache for easier PR review
vincepick May 9, 2025
39f2da0
docs: added git ignore file
vincepick May 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .github/workflows/run_pr_tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Run PR tests, graded and discrim

on:
push:
pull_request:
# only run when PRs target the main branch
branches:
- test/maccGradedCase
- main
types:
- opened
- synchronize
- reopened

jobs:
run-tests:
Expand Down Expand Up @@ -52,8 +57,11 @@ jobs:
sudo apt-get install git-all -y

# Getting current branch
CURRENT_BRANCH="${{ github.ref_name }}"
git clone -b "$CURRENT_BRANCH" https://github.com/stacs-cp/AutoIG.git
REPO="${{ github.repository }}"
CURRENT_BRANCH="${{ github.head_ref }}"
echo "Repository*^*: $REPO"
echo "Branch name*^*: $CURRENT_BRANCH"
git clone -b "${CURRENT_BRANCH}" "https://github.com/${REPO}.git"

# Install Necessary Dependencies into AutoIG Bin
bash bin/install-mininzinc.sh
Expand All @@ -70,18 +78,20 @@ jobs:
cd scripts/testScripts

# Run the two test scripts associated with PRs
echo "About to run pr_discrim tests"
bash check_pr_discrim.sh
bash check_pr.sh
echo "About to run pr_graded tests"
bash check_pr_graded.sh

# if script fails reject PR
- name: Fail
if: ${{ failure() }}
run: |
echo "This tests failed, rejecting PR."
echo "PR tests failed, rejecting."
exit 1
# if script passes approve PR
- name: Pass
if: ${{ success() }}
run: |
echo "This tests passed! allowing PR."
echo "PR tests passed! allowing PR."
exit 0
10 changes: 7 additions & 3 deletions .github/workflows/run_push_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Run push tests, graded and discrim
on:
push:
branches:
- "*"
- "**"

jobs:
run-tests:
Expand Down Expand Up @@ -52,9 +52,13 @@ jobs:
sudo apt-get install r-base -y
sudo apt-get install git-all -y

# Getting current branch
# Getting current branch
REPO="${{ github.repository }}"

CURRENT_BRANCH="${{ github.ref_name }}"
git clone -b "$CURRENT_BRANCH" https://github.com/stacs-cp/AutoIG.git
echo "Repository*^*: $REPO"

git clone -b "$CURRENT_BRANCH" https://github.com/${REPO}.git

# Install Necessary Dependencies into AutoIG Bin
bash bin/install-mininzinc.sh
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore __pycache__ directories
__pycache__/
26 changes: 24 additions & 2 deletions DEV_README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker Build And Run Commands in a Container
 # Docker Build And Run Commands in a Container

### Builds an image of <container-name> using Docker

Expand Down Expand Up @@ -33,17 +33,39 @@ At this point, AutoIG is fully configured and ready for use as normal.

## Example sequence of commands for setting up an experiment:

### To set up for MiniZinc

### Graded Example
`mkdir -p experiments/macc-graded/`

`cd experiments/macc-graded/`

`python $AUTOIG/scripts/setup.py --generatorModel $AUTOIG/data/models/macc/generator-small.essence --problemModel $AUTOIG/data/models/macc/problem.mzn --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver chuffed --solverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 5`

### Discriminating Example
`mkdir -p experiments/macc-discriminating/`

`cd experiments/macc-discriminating/`

`python $AUTOIG/scripts/setup.py --generatorModel $AUTOIG/data/models/macc/generator-small.essence --problemModel $AUTOIG/data/models/macc/problem.mzn --instanceSetting discriminating --minSolverTime 1 --maxSolverTime 3 --baseSolver chuffed --solverFlags="-f" --favouredSolver or-tools --favouredSolverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 5`


### To set up for essence

#### Graded Example
For "vessel_loading" essence problem
`python $AUTOIG/scripts/setup.py --generatorModel $AUTOIG/data/models/vessel-loading/generator.essence --problemModel $AUTOIG/data/models/vessel-loading/problem.essence --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver chuffed --solverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 5`

For "car-sequencing" essence problem
`python $AUTOIG/scripts/setup.py --generatorModel $AUTOIG/data/models/car-sequencing/generator.essence --problemModel $AUTOIG/data/models/car-sequencing/problem.essence --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver chuffed --solverFlags="-f" --maxEvaluations 300 --genSolverTimeLimit 5`

#### Discriminating Example

`python $AUTOIG/scripts/setup.py --generatorModel $AUTOIG/data/models/vessel-loading/generator.essence --problemModel $AUTOIG/data/models/vessel-loading/problem.essence --instanceSetting discriminating --minSolverTime 1 --maxSolverTime 3 --baseSolver chuffed --solverFlags="-f" --favouredSolver ortools --favouredSolverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 5`
### To Run The Generated Bash Script

bash run.sh

# Considerations for Use of Dockerfile

The build Docker image allows for the program to be run in a container. It is worth noting though that the container could take up more storage than running AutoIG through Linux directly, as it will download dependencies within the container such as Python and R. If a users system already has these, it could be more efficient to run it directly on the system without a VM. In addition, data does not persist within the container, so it is important to save the results of AutoIG runs, perhaps with a Docker Volume. Instructions for setting up the Docker Volume are listed above.

4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN echo "$CACHEBUST"

# Clone into AutoIG directory on Vincent fork
# Not incorrect, but will need to be changed later to clone from stacs-cp/AutoIG instead
RUN git clone -b build/update-docker https://github.com/vincepick/AutoIG.git
RUN git clone --depth 1 -b main https://github.com/vincepick/AutoIG.git

WORKDIR /AutoIG

Expand All @@ -59,6 +59,8 @@ RUN bash bin/update-or-path.sh
RUN bash bin/update-conjure-paths.sh

# For use during development

RUN apt-get update
RUN apt-get install -y \
vim \
file
Expand Down
2 changes: 1 addition & 1 deletion bin/R-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ for (p in c("R6","data.table")){
install.packages(paste(binDir,paths[[p]],sep='/'), lib=binDir)
library(p,character.only = TRUE, lib.loc=binDir)
}
}
}
Binary file removed bin/data.table_1.14.2.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions bin/install-irace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ echo ""
echo "============= INSTALLING $name ==================="
echo "$name version: $version"

BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
BIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"

# check if R is installed
if ! [ -x "$(command -v R)" ]; then
Expand All @@ -17,7 +17,7 @@ url="https://cran.r-project.org/src/contrib/irace_3.4.1.tar.gz"

pushd $BIN_DIR

mkdir -p $name
mkdir -p $name

SOURCE_DIR="$name-source"
mkdir -p $SOURCE_DIR
Expand Down
Binary file modified scripts/.DS_Store
Binary file not shown.
135 changes: 97 additions & 38 deletions scripts/collect_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

import sys
import os
import re

scriptDir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(scriptDir)

from minizinc_utils import calculate_minizinc_borda_scores, get_minizinc_problem_type
from essence_pipeline_utils import get_essence_problem_type, calculate_essence_borda_scores

pd.options.mode.chained_assignment = None

Expand Down Expand Up @@ -78,8 +80,8 @@ def rename_status_dis(status, score):
else:
return status
tRs.loc[:,"status"] = [rename_status_dis(s[0],s[1]) for s in zip(tRs.status,tRs.score)]
#display(tRs[tRs.status.str.contains("Wins")])


# rename some columns and re-order the columns
tRs.rename(columns={"hashValue":"instanceHashValue","score":"iraceScore"}, inplace=True)
tRs = tRs[["genInstance","instance","genResults","instanceResults","status","iraceScore","totalTime","instanceHashValue"]]
Expand All @@ -101,6 +103,7 @@ def print_stats(config, tRs, tRsNoDup):
# number of instances generated
nInstances = len(tRsNoDup.instance.unique())


# number of runs for each run status
runStats = tRs.groupby('status').genResults.count().to_dict()
runStatsWithoutDuplicates = tRsNoDup.groupby('status').genResults.count().to_dict()
Expand Down Expand Up @@ -151,44 +154,100 @@ def extract_graded_and_discriminating_instances(runDir):
"""
extract information about graded/discriminating instances and save to a .csv file
"""


outFile = None
if config["instanceSetting"] == "graded":
# filter out non-graded instances
tInfo = tRsNoDup.loc[tRsNoDup.status=="graded",:]
# extract instance type
tInfo.loc[:,"instanceType"] = [x["results"]["main"]["runs"][0]["extra"]["instanceType"] for x in tInfo.instanceResults]
# calculate average solving time for each instance
tInfo.loc[:,"avgSolvingTime"] = [np.mean([rs["time"] for rs in x["results"]["main"]["runs"]]) for x in tInfo.instanceResults]
# re-order columns
tInfo = tInfo[["instance","instanceType","avgSolvingTime","instanceResults","genInstance","genResults","status","iraceScore","totalTime","instanceHashValue"]]
# save to a .csv file
outFile = f"{runDir}/graded-instances-info.csv"
print(f"\nInfo of graded instances is saved to {os.path.abspath(outFile)}")
tInfo.to_csv(outFile, index=False)
if re.search(r'\.mzn$', config["problemModel"]):
if config["instanceSetting"] == "graded":
# filter out non-graded instances
tInfo = tRsNoDup.loc[tRsNoDup.status=="graded",:]
# extract instance type
tInfo.loc[:,"instanceType"] = [x["results"]["main"]["runs"][0]["extra"]["instanceType"] for x in tInfo.instanceResults]
# calculate average solving time for each instance
tInfo.loc[:,"avgSolvingTime"] = [np.mean([rs["time"] for rs in x["results"]["main"]["runs"]]) for x in tInfo.instanceResults]
# re-order columns
tInfo = tInfo[["instance","instanceType","avgSolvingTime","instanceResults","genInstance","genResults","status","iraceScore","totalTime","instanceHashValue"]]
# save to a .csv file
outFile = f"{runDir}/graded-instances-info.csv"
print(f"\nInfo of graded instances is saved to {os.path.abspath(outFile)}")
tInfo.to_csv(outFile, index=False)
else:
# filter out non-discriminating instances or instances where the favoured solver lost
tInfo = tRsNoDup.loc[tRsNoDup.status.isin(["favouredSolverWins"]),:]
# extract instance type
tInfo.loc[:,"instanceType"] = [x["results"]["favoured"]["runs"][0]["extra"]["instanceType"] for x in tInfo.instanceResults]
# extract MiniZinc Borda score of the favoured and the base solvers
print("about to try to get problem type", config["problemModel"])

problemType = get_minizinc_problem_type(config["problemModel"])



def extract_minizinc_score(r):
results = calculate_minizinc_borda_scores(r['base']['runs'][0]['status'], r['favoured']['runs'][0]['status'],
r['base']['runs'][0]['time'], r['favoured']['runs'][0]['time'],
problemType,
r['base']['runs'][0]['extra']['objs'], r['favoured']['runs'][0]['extra']['objs'],
True)
scores = results["complete"] # first element: base solver's score, second element: favoured solver's score
return scores[1]
tInfo.loc[:,"favouredSolverMiniZincScore"] = [extract_minizinc_score(x["results"]) for x in tInfo.instanceResults]
tInfo.loc[:,"baseSolverMiniZincScore"] = [1 - x for x in tInfo.favouredSolverMiniZincScore]
tInfo.loc[:,"discriminatingPower"] = tInfo["favouredSolverMiniZincScore"] / tInfo["baseSolverMiniZincScore"]
# re-order columns
tInfo = tInfo[["instance","discriminatingPower","favouredSolverMiniZincScore","baseSolverMiniZincScore","instanceType","instanceResults","genInstance","genResults","status","iraceScore","totalTime","instanceHashValue"]]
# save to a .csv file
outFile = f"{runDir}/discriminating-instances-info.csv"
print(f"\nInfo of discriminating instances is saved to {os.path.abspath(outFile)}")
tInfo.to_csv(outFile, index=False)

elif re.search(r'\.essence$', config["problemModel"]):
if config["instanceSetting"] == "graded":
# filter out non-graded instances
tInfo = tRsNoDup.loc[tRsNoDup.status=="graded",:]

# extract instance type
tInfo.loc[:,"instanceType"] = [x["results"]["main"]["runs"][0]["status"] for x in tInfo.instanceResults]
# calculate average solving time for each instance
tInfo.loc[:,"avgSolvingTime"] = [np.mean([rs["time"] for rs in x["results"]["main"]["runs"]]) for x in tInfo.instanceResults]
# re-order columns
tInfo = tInfo[["instance","instanceType","avgSolvingTime","instanceResults","genInstance","genResults","status","iraceScore","totalTime","instanceHashValue"]]
# save to a .csv file
outFile = f"{runDir}/graded-instances-info.csv"
print(f"\nInfo of graded instances is saved to {os.path.abspath(outFile)}")
tInfo.to_csv(outFile, index=False)
else:
# filter out non-discriminating instances or instances where the favoured solver lost
tInfo = tRsNoDup.loc[tRsNoDup.status.isin(["favouredSolverWins"]),:]
# The instance type
tInfo.loc[:,"instanceType"] = [x["results"]["favoured"]["runs"][0]["status"] for x in tInfo.instanceResults]
# extract Esesnce Borda score of the favoured and the base solvers

problemType = get_essence_problem_type(config["problemModel"])


def extract_essence_score(r):
# Calculated using only solver time rather than total time of SR + Solver Time
results = calculate_essence_borda_scores(r['base']['runs'][0]['status'], r['favoured']['runs'][0]['status'],
r['base']['runs'][0]['solverTime'], r['favoured']['runs'][0]['solverTime'],
problemType,
True)
# scores = results # first element: base solver's score, second element: favoured solver's score
# Different than the essence pipeline, instaed the calculate_essence_borda_scores calculates the score directly
return results[1]
tInfo.loc[:,"favouredSolverEssenceScore"] = [extract_essence_score(x["results"]) for x in tInfo.instanceResults]
tInfo.loc[:,"baseSolverEssenceScore"] = [1 - x for x in tInfo.favouredSolverEssenceScore]
tInfo.loc[:,"discriminatingPower"] = tInfo["favouredSolverEssenceScore"] / tInfo["baseSolverEssenceScore"]
# re-order columns
tInfo = tInfo[["instance","discriminatingPower","favouredSolverEssenceScore","baseSolverEssenceScore","instanceType","instanceResults","genInstance","genResults","status","iraceScore","totalTime","instanceHashValue"]]
# save to a .csv file
outFile = f"{runDir}/discriminating-instances-info.csv"
print(f"\nInfo of discriminating instances is saved to {os.path.abspath(outFile)}")
tInfo.to_csv(outFile, index=False)
else:
# filter out non-discriminating instances or instances where the favoured solver lost
tInfo = tRsNoDup.loc[tRsNoDup.status.isin(["favouredSolverWins"]),:]
# extract instance type
tInfo.loc[:,"instanceType"] = [x["results"]["favoured"]["runs"][0]["extra"]["instanceType"] for x in tInfo.instanceResults]
# extract MiniZinc Borda score of the favoured and the base solvers
problemType = get_minizinc_problem_type(config["problemModel"])
def extract_minizinc_score(r):
results = calculate_minizinc_borda_scores(r['base']['runs'][0]['status'], r['favoured']['runs'][0]['status'],
r['base']['runs'][0]['time'], r['favoured']['runs'][0]['time'],
problemType,
r['base']['runs'][0]['extra']['objs'], r['favoured']['runs'][0]['extra']['objs'],
True)
scores = results["complete"] # first element: base solver's score, second element: favoured solver's score
return scores[1]
tInfo.loc[:,"favouredSolverMiniZincScore"] = [extract_minizinc_score(x["results"]) for x in tInfo.instanceResults]
tInfo.loc[:,"baseSolverMiniZincScore"] = [1 - x for x in tInfo.favouredSolverMiniZincScore]
tInfo.loc[:,"discriminatingPower"] = tInfo["favouredSolverMiniZincScore"] / tInfo["baseSolverMiniZincScore"]
# re-order columns
tInfo = tInfo[["instance","discriminatingPower","favouredSolverMiniZincScore","baseSolverMiniZincScore","instanceType","instanceResults","genInstance","genResults","status","iraceScore","totalTime","instanceHashValue"]]
# save to a .csv file
outFile = f"{runDir}/discriminating-instances-info.csv"
print(f"\nInfo of discriminating instances is saved to {os.path.abspath(outFile)}")
tInfo.to_csv(outFile, index=False)
# there are no other supported model types for now
print("Unsupported model type, please try agian with Essence or Mzn problem model")


return tInfo

Expand Down
25 changes: 25 additions & 0 deletions scripts/conf.py
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
problemType = None

# Define constants for scoring

# General
SCORE_UNWANTED_TYPE = 0
SCORE_TOO_EASY = 0
SCORE_INCORRECT_ANSWER = 0
SCORE_TOO_DIFFICULT = 0

# Graded
SCORE_GRADED = -1

# Discriminating
SCORE_BASE_TOO_EASY = 0
SCORE_FAVOURED_TOO_DIFFICULT = 0
# Best when one can do it but the other can't
SCORE_BEST = -9999



# Define constants for outputs
detailedOutputDir = "./detailed-output"

# for minizinc experiments only: solvers where -r doesn't work when being called via minizinc
deterministicSolvers = ["ortools"]
Loading