Skip to content

Experiment Setup for XCSP3 Mini Track

Max Bourgeat edited this page May 31, 2023 · 15 revisions

Getting the Competition Instances

This script can be used to download and extract the instances for the mini track of the XCSP3 competition.

#!/bin/bash

wget https://www.cril.univ-artois.fr/~lecoutre/compets/instancesXCSP22.zip
unzip instancesXCSP22.zip 
rm -rf instancesXCSP22.zip
rm -rf instancesXCSP22/COP
rm -rf instancesXCSP22/CSP
cd instancesXCSP22
cd MiniCOP
for lzma_file in *.lzma; do xz --decompress "$lzma_file"; done
cd ../MiniCSP
for lzma_file in *.lzma; do xz --decompress "$lzma_file"; done
cd ../../

Setting up the env

  1. Connect to the host
  2. Git pull SeaPearl and complete the setup with the following bash script:

For Julia 1.8

#!/bin/bash
git clone https://github.com/corail-research/SeaPearl.jl.git

# Check if Julia is already installed
module load julia
if ! command -v julia &> /dev/null
then
    echo "Julia could not be found. Installing..."
    wget https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.0-linux-x86_64.tar.gz
    tar -xvzf julia-1.8.0-linux-x86_64.tar.gz
    sudo mv julia-1.8.0 /opt/
    sudo ln -s /opt/julia-1.8.0/bin/julia /usr/local/bin/julia
    echo "Julia 1.8.0 has been installed"
else
    echo "Julia is already installed"
fi

cd SeaPearl.jl

# Activate the project and add the packages
julia --eval 'using Pkg; Pkg.activate("."); Pkg.instantiate(); Pkg.precompile()'

Julia 1.9

#!/bin/bash
git clone https://github.com/corail-research/SeaPearl.jl.git

# Check if Julia is already installed
module load julia
if ! command -v julia &> /dev/null
then
    echo "Julia could not be found. Installing..."
    wget https://julialang-s3.julialang.org/bin/linux/x64/1.9/julia-1.9.0-linux-x86_64.tar.gz
    tar -xvzf julia-1.9.0-linux-x86_64.tar.gz
    sudo mv julia-1.9.0 /opt/
    sudo ln -s /opt/julia-1.9.0/bin/julia /usr/local/bin/julia
    echo "Julia 1.9.0 has been installed"
else
    echo "Julia is already installed"
fi

cd SeaPearl.jl

# Activate the project and add the packages
julia --eval 'using Pkg; Pkg.activate("."); Pkg.instantiate(); Pkg.precompile()'

  1. At this point, the setup should be complete. You can now evaluate the solver on the instances. You should be able to iterate over the XCSP3 instances using this bash script:
#!/bin/bash

# Directory containing the XML files
directory="../instancesXCSP22"

# Find all XML files recursively in the directory
xml_files=$(find "$directory" -type f -name "*.xml")
# Keep track of the count per prefix
declare -A prefix_count

# Iterate over each XML file
for xml_file in $xml_files; do
    # Extract the prefix from the file name
    prefix=$(basename "$xml_file" | awk -F "-" '{print $1}')

    # Check if the prefix count exceeds three
    if [[ ${prefix_count[$prefix]} -lt 3 ]]; then
        # Process the XML file (replace with your desired command)
        echo "Processing $xml_file"

    
        # Run the Julia file and handle any errors
        julia --project src/argparse_setting.jl -b "$xml_file" -t 1800 |& tee -a test_output.txt
        exit_code=$?
    
        if [ $exit_code -ne 0 ]; then
            echo "Julia script encountered an error for $xml_file (Exit code: $exit_code)"
        fi

        # Increment the prefix count
        prefix_count[$prefix]=$(( ${prefix_count[$prefix]} + 1 ))
    fi    
done

  1. Copying files from remote Once your experiments have run, you can use scp to transfer the files generated. To transfer a single file: scp username@remote_ip_address:/path/to/remote/file /path/to/local/destination Or to transfer an entire directory: scp -r username@remote_ip_address:/path/to/remote/directory /path/to/local/destination