Commit b737c3ed authored by Blais, Chris's avatar Blais, Chris
Browse files

adding ccro layout test split script for cades

parent f3ab2bf6
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
from context import *
import numpy as np
from testing.run_soar_comparison import test_compare_methods
import argparse


def run_ccro_bilinear_split(part):
    """
    splits the bilinear layout list into 10 different layouts. 
    part: an integer from 0 to 9, indicating which part of the layout splits to run.
    """
    # split 2**16 layouts (65536) into 10 different layouts, so each layout has 6553 or 6554 layouts
    all_layout_words = list(range(2**16))
    layout_splits = np.array_split(all_layout_words, 10)

    # 
    testfolder = os.path.dirname(os.path.abspath(__file__))
    test_compare_methods(
        system = "ccro", 
        objective="linear", 
        ptype=200, 
        reddeficit=True,
        test_layouts = layout_splits[part],
        overwrite=True,
        verbose=0,
        test_folder=testfolder,
        results_filename = f"ccro_bilinear_layout_part{part}",
    )

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run CCRO bilinear split")
    parser.add_argument("part", type=int, help="Part of the layout split to run")
    args = parser.parse_args()
    run_ccro_bilinear_split(args.part)

testing/run_ccro.sh

0 → 100644
+30 −0
Original line number Diff line number Diff line
#!/bin/bash

#SBATCH -A birthright
#SBATCH -p batch
#SBATCH -N 1
#SBATCH -n 10
#SBATCH -c 2
#SBATCH -J ccro_comp_bl
#SBATCH --mem=100g
#SBATCH -t 00-10:00:00
#SBATCH -o ./ccro_comp_bl-out.log
#SBATCH -e ./ccro_comp_bl.log
#SBATCH --mail-type=FAIL,END
#SBATCH --mail-user=blaiscj@ornl.gov

# sbatch arguments
source ~/.bashrc
conda activate wwtp
cd /home/tjf/01_nawi/soar_integration/papers/papers/01_genobs_discrepancy_paper_2026
srun -n1 --exclusive python run_ccro_bilinear_split --part=0 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=1 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=2 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=3 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=4 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=5 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=6 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=7 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=8 &
srun -n1 --exclusive python run_ccro_bilinear_split --part=9 &
wait
 No newline at end of file
+11 −5
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ def test_compare_methods(
        overwrite=False,
        verbose=0,
        test_folder=None,
        results_filename = None,
    ):
    """
    Docstring for test_compare_methods
@@ -121,7 +122,7 @@ def test_compare_methods(
                random.seed(42)
                results = random.choices(range(0, maxSensWord), k=nTestLayouts)

    elif isinstance(test_layouts, list):
    elif isinstance(test_layouts, list) or isinstance(test_layouts, np.ndarray):
        results = test_layouts

    # progress bar
@@ -319,11 +320,16 @@ def test_compare_methods(
    print(f"RREF agree SOAR, LU or qr disagree in {nsuccess_rref} layouts out of {len(results)}")
    results_log_path = os.path.join(results_folder, f"{system}_{objective}_{reddeficit_str}_{str(ptype)}.pkl")

    if overwrite:
        results_log_path = os.path.join(results_folder, f"{system}_{objective}_{reddeficit_str}_{str(ptype)}.pkl")
    # specify results filename if given, otherwise use default naming convention 
    if results_filename is not None:
        results_log_path = os.path.join(results_folder, f"{results_filename}.pkl")
    else:
        curr_date = datetime.datetime.today().strftime('%Y_%m_%d_%H_%M_%S')
        results_log_path = os.path.join(results_folder, f"{system}_{objective}_{reddeficit_str}_{str(ptype)}_{curr_date}.pkl")
        results_log_path = os.path.join(results_folder, f"{system}_{objective}_{reddeficit_str}_{str(ptype)}.pkl")

    # check if file exists, if so add timestamp to end. 
    if os.path.exists(results_log_path) and not overwrite:
        results_log_path = results_log_path[:-4] + f"_{datetime.datetime.today().strftime('%Y_%m_%d_%H_%M_%S')}.pkl"
        print(f"file already exists, saving to {results_log_path} instead")
    
    print(f"saving results to file: {results_log_path}")