pyepo.data.dataset

optDataset class based on PyTorch Dataset

Classes

optDataset

This class is a Torch Dataset for optimization problems.

optDatasetKNN

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

Module Contents

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

Bases: torch.utils.data.Dataset

This class is a Torch Dataset for optimization problems.

model

Optimization model

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

model
feats
costs
sols
objs
_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 a Torch Dataset for optimization problems, when using the robust kNN-loss.

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

model

Optimization model

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

model
k = 10
weight = 0.5
feats
costs
sols
objs
_getSols()

A method to get optimal solutions for all cost vectors

_getKNN()

A method to get kNN costs