-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
125 additions
and
69 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import pickle | ||
import os | ||
import dimod | ||
from AGV_quantum import get_results, LinearProg | ||
|
||
|
||
from pathlib import Path | ||
|
||
import argparse | ||
parser = argparse.ArgumentParser("Solve linear or quadratic") | ||
parser.add_argument( | ||
"--example", | ||
type=str, | ||
help="chose example out of [tiny, smallest, small, medium_small, medium, large, largest]", | ||
default="small", | ||
) | ||
parser.add_argument( | ||
"--hyb_solver", | ||
type=str, | ||
help="chose bqm or cqm", | ||
default="bqm", | ||
) | ||
|
||
args = parser.parse_args() | ||
cwd = os.getcwd() | ||
|
||
if args.example == "tiny": | ||
sol_folder = Path("annealing_results/tiny_2_AGV") | ||
if args.example == "smallest": | ||
sol_folder = Path("annealing_results/2_AGV") | ||
if args.example == "small": | ||
sol_folder = Path("annealing_results/4_AGV") | ||
if args.example == "medium_small": | ||
sol_folder = Path("annealing_results/6_AGV") | ||
if args.example == "medium": | ||
sol_folder = Path("annealing_results/7_AGV") | ||
if args.example == "large": | ||
sol_folder = Path("annealing_results/12_AGV") | ||
if args.example == "largest": | ||
sol_folder = Path("annealing_results/15_AGV") | ||
|
||
lp_folder = Path(f"lp_files/lp_{args.example}.pkl") | ||
|
||
assert args.hyb_solver in ["bqm", "cqm"] | ||
|
||
hybrid = args.hyb_solver | ||
|
||
with open(os.path.join(cwd, sol_folder, f"new_{hybrid}.pkl"), "rb") as f: | ||
sampleset = pickle.load(f) | ||
|
||
with open(os.path.join(cwd, lp_folder), "rb") as f: | ||
lp = pickle.load(f) | ||
|
||
sampleset = dimod.SampleSet.from_serializable(sampleset) | ||
|
||
if __name__ == '__main__': | ||
|
||
if hybrid == "bqm": | ||
print(sampleset.info) | ||
p=5 | ||
lp.to_bqm_qubo_ising(p) | ||
sampleset = lp.interpreter(sampleset) | ||
solutions = get_results(sampleset, lp) | ||
print(solutions) | ||
|
||
|
||
elif hybrid == "cqm": | ||
print(sampleset.info) | ||
solutions = get_results(sampleset, lp) | ||
for sol in solutions: | ||
if sol["feasible"]: | ||
print(sol) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters