Skip to content

AlexKressner/scip_ray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building a SCIP optimization factory with Ray on Azure

Most of us in ORMS know this situation: You have a neat mathematical optimization model (LP, MIP, ...) and want to run different experiments, i.e. use the same model with different problem data or solver settings. Consider the case where you do 75 experiments and each one takes 10 minutes. If you do the computations sequentially this sums up to 750 minutes or 12.5 hours. I remember the days when I started my laptop in the evening and had a look at the computations the next day in the morning - just to notice that I have to change something sooner or later (fix bugs, adjust the model, change the parameters, etc.) and do the computations again.

What if you could easily spin up an arbitrary large cluster of high-performance virtual machines in the cloud and do massive optimization exeperiments in parallel? Something like a solver factory...!

If this got you interest, have a look at this repo and see how to scale the non-commercial solver SCIP with Ray on Azure (you can also deploy to other cloud providers). For demonstration purposes, let's use the good old capacitated lot sizing problem and a small problem instance which SCIP can solve in approximately 27 seconds (optimization runs in one process with one CPU). Given a problem set of 100 of those small instances and sequential execution, you will have to wait for 2700 seconds until all experiments are done. Spinning up a ray cluster with three virtual maschines (3 node with 8 CPU each) on Azure, parallel execution will give you a boost in experimentation speed of factor 20 utilizing all 24 cores at the same time (130 seconds to solve all problem instances).

Files

  • script.py: SCIP implementation of CLSP and ray code
  • config.yaml: Config file to deploy ray cluster including set up commands for pyscipopt
  • data/: Folder containing problem data which is synced to nodes in ray cluster
  • requirements.txt: Python dependencies

Getting started

Note: Ray is under heavy development and I have sometimes experienced issues in setting up a proper cluster. Most of the problems I had to deal with stem from the Azure SDK used in ray. In case of any problems have a look at the issues documented on github for ray. The ray command ray monitor config.yaml is helpful to see logs and to better understand bugs. I will have a look at new ray releases from time to time and pin dependencies when stable. At the moment I am pulling wheel files for ray from the latest master commit.

  1. Make sure you have the Azure CLI installed
  2. Log in using az login, then configure your credentials with az account set -s <subscription_id>.
  3. Clone repo
  git clone https://github.com/AlexKressner/scip_ray && cd scip_ray
  1. Make a virtual environment and install dependencies. Ray is pinned to current master commit. Make sure to choose the correct wheel for your operating system - I am on MacOS!
  pip install -r requirements.txt
  1. Configure the size of your cluster by editing config.yaml(see syntax here)
    • Set the number of virtual machines: max_workers: 2
    • Set the number of CPUs to use on each machine (head and worker nodes): resources: {"CPU": 8}
    • Set the type of virtual machine to launch: Standard_F8s_v2 (8 vCPUs and 16 GiB memory, more virtual machine types can be found here)
  2. Make sure to increase your quotas on Azure to launch your cluster. See instructions here.
  3. Launch the cluster
  ray up -y config.yaml --no-config-cache
  1. Run optimization in the cloud
  ray submit config.yaml script.py
  1. Open another terminal and start ray dashboard
  ray dashboard config.yaml

  1. Bring down the cluster
  ray down -y config.yaml

Releases

No releases published

Packages

No packages published

Languages