semvec/pypi-packages huggingface dataset:
pytxc 0.1.6
Python parser from TransXChange.
License: MIT
Requires Python: >=3.8,<4.0

# pytxc

[![test](https://github.com/ciaranmccormick/pytxc/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/ciaranmccormick/pytxc/actions/workflows/test.yml)
[![Python Version](https://img.shields.io/pypi/pyversions/pytxc.svg)](https://pypi.org/project/pytxc/)
[![codecov](https://codecov.io/gh/ciaranmccormick/pytxc/branch/main/graph/badge.svg?token=RIZHOMHC19)](https://codecov.io/gh/ciaranmccormick/pytxc)

## Quick start

### Installation

Use `pip` to install `pytxc`.

```console
python -m pip install pytxc
```

### Usage

The `Timetable` class is used to parse and interact with
TransXChange files.


```python
from pathlib import Path
from pytxc import Timetable


>> filepath = "path/to/transxchange/file.xml"
>> timetable = Timetable.from_file_path(Path(filepath))
>> timetable.header
Header(
    creation_date_time=datetime.datetime(2020, 11, 22, 11, 0),
    modification_date_time=datetime.datetime(2021, 12, 17, 11, 8, 35),
    file_name="file.xml",
    modification="revise",
    schema_version="2.4",
    revision_number=159,
)
```

The `StopPoint`s in a TransXChange can be accessed through the `stop_points`
attribute.

```python
>> timetable.stop_points[0]

AnnotatedStopPointRef(
    stop_point_ref=StopPointRef(text="077072002S"),
    common_name="High Street Stand S",
)
```

Similarly, `RouteSections` can be accessed using the `route_sections` attribute.

```python
>> timetable.route_sections[0]

RouteSection(id='RS1')
```

The naming conventions used for the Python objects will more or less match those
of TransXChange for example, the first `JourneyPattern` of a `StandardService` is
usually found in a `Service` of the `Services` block.
Using `pytxc` it can be accessed as follows,

```python
>> timetable.services[0].standard_services[0].journey_patterns[0]

JourneyPattern(
    id="JP1",
    CreationDateTime="2020-11-22T11:00:00",
    ModificationDateTime="2021-12-17T11:08:35",
    Modification="revise",
    RevisionNumber="159",
)
```

When interacting with references, `pytxc` provides a `resolve` method to find
the original element in the TransXChange file. For example if a `JourneyPattern`
contains a `RouteRef` then calling `resolve` on the `route_ref` object will
return the original `Route` object.

```python
>> jp = timetable.services[0].standard_services[0].journey_patterns[0]
>> jp.route_ref.resolve()

Route(private_code='35st-40', description='Stockton - Wolviston Court')
```
mmrbipy 1.1.2
mmrbipy: A solver for the min-max regret binary integer programming problem (MMR-BIP)
License: MIT
Requires Python: >=3.6

# mmrbipy: A solver for the min-max regret binary integer programming problem (MMR-BIP)

## Installation

In a virtual environment with Python 3.6+, mmrbipy can be installed via

```bash
pip install mmrbipy
```

## Using mmrbipy

With a compatible instance file, mmrbipy solves the MMR-BIP from a Python script:

```python
from mmrbipy import Model

# Generate a model from instance file
mod = Model(problem='kp', filename='../instance/KP/1-70-01-45-20')

# Solve by iDS algorithm with best-scenario constraints
mod.solve(algorithm='ids-b', timelimit=100)

# Print results
print("objective value: {}".format(mod.objval))
print("time to best: {:.2f}".format(mod.ttb))

# Write the results to file
mod.write("result.txt")
```
## Model
To solve the MMR-BIP, mmrbipy provides five types of instance format:

- min-max binary integer programming problem (*bip*)
- min-max regret knapsack problem (*kp*)
- min-max regret multidimensional knapsack problem (*mkp*)
- min-max regret set covering problem (*scp*)
- min-max regret generalized assignment problem (*gap*)

See [instance page](https://github.com/ebeleta/iDS/tree/main/instance) for the details of each type

### Set problem type in constructor of _Model_ class
```python
# Generate a model from instance file
mod = Model(problem='kp', filename='../instance/KP/1-70-01-45-20')
```

_Note: Benchmark instances for_

- _min-max regret knapsack problem_
- _min-max regret multidimensional knapsack problem_
- _min-max regret set covering problem_
- _min-max regret generalized assignment problem_

_are available in the `instance` directory on the [project's homepage](https://github.com/ebeleta/iDS/). For easy access to the example files, we recommend cloning the repository._

## Algorithm

To solve the MMR-BIP, mmrbipy provides the following algorithms:
- fixed scenario algorithm (*fix*);
- Benders-like decomposition algorithm (*bd*);
- branch-and-cut algorithm with Benders cuts (*bc*);
- dual substitution algorithm (*ds*);
- iterated dual substitution algorithm with best-scenario constraints (*ids-b*);
- iterated dual substitution algorithm with Hamming-distance constraints (*ids-h*);
- branch-and-cut algorithm for dual substitution model with best-scenario constraints (*bcds-b*);
- branch-and-cut algorithm for dual substitution model with Hamming-distance constraints (*bcds-h*).

### Set algorithm type in _solve_ function
```python
# Solve by iDS algorithm with best-scenario constraints
mod.solve(algorithm='ids-b', timelimit=100)
```

_Note: The implement are based on [gurobypy](https://pypi.org/project/gurobipy/)._

## Additional information

For more information about the algorithms used in the solver, see [Wu et al. (2022)](https://doi.org/10.1287/ijoc.2022.1189).