Code for the paper "Smart 'Predict, then Optimize'" by Adam Elmachtoub and Paul Grigas.
The code will run on Julia v1.5.0 and requires several packages as listed in the headers of various files.
This code is helpful for replicating the experiments in the above paper. For training your own models on your own data using SPO+, it is recommended to use the excellent PyEPO package by Bo Tang and Elias B. Khalil.
The code is divided into several folders:
solvercontains all of the files needed to run the SPO+ (SGD and reformulation approaches), random forests, least squares, and least absolute loss methods.oraclescontains examples of optimization oracles such as shortest path and portfolio optimization.testscontains some basic sanity check tests.experimentscontains files concerning the experiments in the paper.plotscontains R code for constructing the plots in the paper.
The solver folder contains the files reformulation.jl and sgd.jl for training a model with the SPO+ loss function using a fixed value of the regularization parameter. To actually a train a model in practice, it is recommended to use the file validation_set.jl and the corresponding function is validation_set_alg, which additionally performs cross-validation using the validation set approach. The documentation in the file explains the syntax for calling the validation_set_alg function.
The files in the folder experiments can simply be run to replicate the experiments included in the paper.