https://github.com/juliuste/parse-gurobi-solution
Parse .sol solution files generated by the Gurobi solver.
https://github.com/juliuste/parse-gurobi-solution
library
Last synced: 8 months ago
JSON representation
Parse .sol solution files generated by the Gurobi solver.
- Host: GitHub
- URL: https://github.com/juliuste/parse-gurobi-solution
- Owner: juliuste
- License: isc
- Created: 2018-07-23T20:44:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-25T04:12:40.000Z (about 6 years ago)
- Last Synced: 2025-01-25T16:25:33.239Z (over 1 year ago)
- Topics: library
- Language: JavaScript
- Size: 13.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# parse-gurobi-solution
Parse [.sol solution files](https://www.gurobi.com/documentation/8.0/refman/sol_format.html) generated by the [Gurobi](https://www.gurobi.com/) solver.
[](https://www.npmjs.com/package/parse-gurobi-solution)
[](https://travis-ci.org/juliuste/parse-gurobi-solution)
[](https://greenkeeper.io/)
[](https://david-dm.org/juliuste/parse-gurobi-solution)
[](license)
[](https://gitter.im/juliuste)
## Installation
```shell
npm install parse-gurobi-solution
```
## Usage
The method exposed by this module takes a single `fileStream` parameter, which is a stream of your `.sol` solution file and returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) that will resolve in an object with your variable names as keys.
```javascript
const fs = require('fs')
const parseGurobiSolution = require('parse-gurobi-solution')
const fileStream = fs.createReadStream('./solution.sol')
const solution = parseGurobiSolution(fileStream).then(console.log) // Promise
```
The following solution file example:
```
# Objective value = 3.6700000000001825e+02
a0 1
a1 2.128473937036380e-7
b0 3.1268
b1 2
xcoord 10
ycoord 0
lat 2.91256
```
would give you a `solution` object that looks as follows:
```js
{
a0: 1,
a1: 2.12847393703638e-7,
b0: 3.1268,
b1: 2,
xcoord: 10,
ycoord: 0,
lat: 2.91256
}
```
## Contributing
If you found a bug or want to propose a feature, feel free to visit [the issues page](https://github.com/juliuste/parse-gurobi-solution/issues).