Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprk 331 #135

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions Documentation/source/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ make
cp VRP_SISRs ../
```

#### Untested: FastVC2+p and MetaVC

FastVC2+p and MetaVC require `glibc-static` in order to compile, and are currently untested within Sparkle. Therefore none of the examples below make use of these solvers, but they are available in the downloadable resources.
It can be recompiled as follows in the `Examples/Resources/MinVC/Solvers/FastVC2+p` directory:

```bash
unzip FastVC2+p_std_source_code.zip
cd FastVC2+p_std_source_code
make

```

```{include} ../../Examples/configuration_runtime.md
```

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""FastVC2+p solver wrapper."""
import sys
import subprocess
from pathlib import Path
from sparkle.types import SolverStatus
from sparkle.tools.solver_wrapper_parsing import parse_solver_wrapper_args

# Convert the arguments to a dictionary
args = parse_solver_wrapper_args(sys.argv[1:])

# Extract and delete data that needs specific formatting
solver_dir = Path(args["solver_dir"])
instance = Path(args["instance"])
seed = args["seed"]
cutoff = args["cutoff_time"]

del args["solver_dir"]
del args["instance"]
del args["cutoff_time"]
del args["seed"]

solver_name = "fastvc2+p"
if solver_dir != Path("."):
solver_exec = f"{solver_dir / solver_name}"
else:
f"./{solver_name}"

# NOTE: This algorithm requires the cutoff time, but to ensure consistent runtime
# measurements by Sparkle we multiply it by 10 to make sure the algorithm does not
# stop early, but is stopped by Sparkle (runsolver) consistenty with other solvers

# NOTE: Unused optional arguments:
# -opt <optimal_size>
# -cand_count <cand_count>
solver_cmd = [solver_exec,
"-inst", str(instance),
"-seed", str(seed),
"-cutoff_time", str(cutoff * 10)]

# Construct call from args dictionary
params = []
for key in args:
if args[key] is not None:
params.extend(["-" + str(key), str(args[key])])

try:
solver_call = subprocess.run(solver_cmd + params,
capture_output=True)
except Exception as ex:
print(f"Solver call failed with exception:\n{ex}")

# Convert Solver output to dictionary for configurator target algorithm script
output_str = solver_call.stdout.decode()
# Optional: Print original output so the solution can be verified by SATVerifier
print(output_str)

status = SolverStatus.UNKNOWN
solution_quality = sys.maxsize
for line in output_str.splitlines():
words = line.strip().split()
if len(words) <= 0:
continue
if len(words) >= 4 and words[1] == 'c' and words[2] == 'Arguments' and \
words[3] == 'Error!':
status = SolverStatus.CRASHED
break
if len(words) >= 4 and words[1] == 'c' and words[2] == 'vertex_cover:':
temp_solution_quality = int(words[3])
if solution_quality < 0 or temp_solution_quality < solution_quality:
solution_quality = temp_solution_quality
status = SolverStatus.SUCCESS

outdir = {"status": status.value,
"quality": solution_quality,
"solver_call": solver_cmd + params}

print(outdir)

This file was deleted.

Loading
Loading