Warcraft

Public

Private

DecisionFocusedLearningBenchmarks.Utils.generate_datasetFunction
generate_dataset(::WarcraftBenchmark) -> Vector
generate_dataset(
    ::WarcraftBenchmark,
    dataset_size::Int64
) -> Vector

Downloads and decompresses the Warcraft dataset the first time it is called.

Warning

dataset_size is capped at 10000, i.e. the number of available samples in the dataset files.

source
DecisionFocusedLearningBenchmarks.Utils.generate_maximizerMethod
generate_maximizer(
    ::WarcraftBenchmark;
    dijkstra
) -> typeof(DecisionFocusedLearningBenchmarks.Warcraft.dijkstra_maximizer)

Returns an optimization algorithm that computes a longest path on the grid graph with given weights. Uses a shortest path algorithm on opposite weights to get the longest path.

source
DecisionFocusedLearningBenchmarks.Utils.generate_statistical_modelMethod
generate_statistical_model(
    ::WarcraftBenchmark;
    seed
) -> Flux.Chain{T} where T<:Tuple{Any, Any, Any, Any, Flux.AdaptiveMaxPool{4, 2}, typeof(DecisionFocusedLearningBenchmarks.Utils.average_tensor), typeof(DecisionFocusedLearningBenchmarks.Utils.neg_tensor), typeof(DecisionFocusedLearningBenchmarks.Utils.squeeze_last_dims)}

Create and return a Flux.Chain embedding for the Warcraft terrains, inspired by differentiation of blackbox combinatorial solvers.

The embedding is made as follows:

  1. The first 5 layers of ResNet18 (convolution, batch normalization, relu, maxpooling and first resnet block).
  2. An adaptive maxpooling layer to get a (12x12x64) tensor per input image.
  3. An average over the third axis (of size 64) to get a (12x12x1) tensor per input image.
  4. The element-wize neg_tensor function to get cell weights of proper sign to apply shortest path algorithms.
  5. A squeeze function to forget the two last dimensions.
source
DecisionFocusedLearningBenchmarks.Utils.plot_dataMethod
plot_data(
    ::WarcraftBenchmark,
    sample::DataSample;
    θ_true,
    θ_title,
    y_title,
    kwargs...
) -> Any

Plot the content of input DataSample as images. x as the initial image, θ as the weights, and y as the path.

The keyword argument θ_true is used to set the color range of the weights plot.

source
DecisionFocusedLearningBenchmarks.Warcraft.create_datasetMethod
create_dataset(
    decompressed_path::String,
    nb_samples::Int64
) -> Vector

Create the dataset corresponding to the data located at decompressed_path, possibly sub-sampling nb_samples points. The dataset is made of images of Warcraft terrains, cell cost labels and shortest path labels. It is a Vector of tuples, each Tuple being a dataset point.

source
DecisionFocusedLearningBenchmarks.Warcraft.dijkstra_maximizerMethod
dijkstra_maximizer(
    θ::AbstractMatrix;
    kwargs...
) -> Matrix{Int64}

Computes the longest path in given grid graph weights by computing the shortest path in the graph with opposite weights. Using the Dijkstra algorithm.

Warning

Only works on graph with positive weights, i.e. if θ only contains negative values.

source
DecisionFocusedLearningBenchmarks.Warcraft.read_datasetFunction
read_dataset(
    decompressed_path::String
) -> Tuple{Any, Any, Any}
read_dataset(
    decompressed_path::String,
    dtype::String
) -> Tuple{Any, Any, Any}

Read the dataset of type dtype at the decompressed_path location. The dataset is made of images of Warcraft terrains, cell cost labels and shortest path labels. They are returned separately, with proper axis permutation and image scaling to be consistent with Flux embeddings.

source