项目作者: fruchtfolge

项目描述 :
NEOS Server JS Client
高级语言: GAMS
项目地址: git://github.com/fruchtfolge/neos-js.git
创建时间: 2018-08-05T19:45:58Z
项目社区:https://github.com/fruchtfolge/neos-js

开源协议:MIT License

下载


NEOS Server JavaScript Client

A complete XML-RPC client for the Neos Numerical Optimisation Server. Works in the browser and Node.js

For parsing the results of a GAMS job returned by NEOS, check out gams2js!

Installation

To install via npm:

  1. npm install neos-js

Or grab a release archive file from the dist folder.

Examples

Browser:
In the header include

  1. <script src="assets/neos.min.js"></script>

then

  1. <script type="text/javascript">
  2. NEOS.xmlstring({
  3. category: 'LP',
  4. solver: 'CPLEX',
  5. inputMethod: 'GAMS',
  6. model: simulationModelString,
  7. email: 'test@test.com'
  8. })
  9. .then(NEOS.submitJob)
  10. .then(NEOS.getFinalResults)
  11. .then(res => {
  12. // work with the resulting listing file
  13. })
  14. .catch(err => {
  15. // catch errors
  16. })
  17. </script>

Check out the NEOS online editor example

Node.js

  1. const NEOS = require('neos-js')
  2. const fs = require('fs')
  3. // load a simulation model, in this case a GAMS file
  4. const model = fs.readFileSync('transport_model.gms', 'utf-8')
  5. // convert the simulation model into a NEOS XML string,
  6. // solve and await the results
  7. NEOS.xmlstring({
  8. category: 'LP',
  9. solver: 'CPLEX',
  10. inputMethod: 'GAMS',
  11. model: simulationModelString,
  12. email: 'test@test.com'
  13. })
  14. .then(NEOS.submitJob)
  15. .then(NEOS.getFinalResults)
  16. .then(res => {
  17. // work with the resulting listing file
  18. })
  19. .catch(err => {
  20. // catch errors
  21. })

Methods

For a complete list of the available methods, visit the Neos Server XML-RPC API documentation.

Additional methods:

  1. prepareJob(template, model, email)

Convenience method. Converts your simulation model (string) into the required NEOS XML format that you get from the getSolverTemplate method. An email is required for some solvers (e.g. CPLEX), so make sure to pass one.

  1. xmlstring(json)

Convert a JavaScript object containing the properties required for running a NEOS
job into a NEOS compatible XML string. The object properties should adhere to the
properties retrieved from the getSolverTemplate method (without the surrounding document tag).

  1. parseXML(xmlstring)

Parse an XML string retrieved by NEOS, e.g. the result from the getSolverTemplate
call.

Contribution

Contribution is highly appreciated! Make sure to npm test before submitting a PR

License

MIT