pyepo.data.dataset

optDataset class based on PyTorch Dataset

Module Contents

Classes

optDataset

This class is Torch Dataset for optimization problems.

optDatasetKNN

This class is Torch Dataset for optimization problems, when using the robust kNN-loss.

class pyepo.data.dataset.optDataset(model, feats, costs)

Bases: torch.utils.data.Dataset

This class is Torch Dataset for optimization problems.

model

Optimization models

Type:

optModel

feats

Data features

Type:

np.ndarray

costs

Cost vectors

Type:

np.ndarray

sols

Optimal solutions

Type:

np.ndarray

objs

Optimal objective values

Type:

np.ndarray

_getSols()

A method to get optimal solutions for all cost vectors

_solve(cost)

A method to solve optimization problem to get an optimal solution with given cost

Parameters:

cost (np.ndarray) – cost of objective function

Returns:

optimal solution (np.ndarray) and objective value (float)

Return type:

tuple

__len__()

A method to get data size

Returns:

the number of optimization problems

Return type:

int

__getitem__(index)

A method to retrieve data

Parameters:

index (int) – data index

Returns:

data features (torch.tensor), costs (torch.tensor), optimal solutions (torch.tensor) and objective values (torch.tensor)

Return type:

tuple

class pyepo.data.dataset.optDatasetKNN(model, feats, costs, k=10, weight=0.5)

Bases: optDataset

This class is Torch Dataset for optimization problems, when using the robust kNN-loss.

Reference: <https://arxiv.org/abs/2310.04328>

model

Optimization models

Type:

optModel

k

number of nearest neighbours selected

Type:

int

weight

weight of kNN-loss

Type:

float

feats

Data features

Type:

np.ndarray

costs

Cost vectors

Type:

np.ndarray

sols

Optimal solutions

Type:

np.ndarray

objs

Optimal objective values

Type:

np.ndarray

_getSols()

A method to get optimal solutions for all cost vectors

_getKNN()

A method to get kNN costs