Coder Social home page Coder Social logo

fruchtfolge / neos-js Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 1.0 281 KB

NEOS Server JS Client

Home Page: https://fruchtfolge.github.io/neos-js/index.html

License: MIT License

JavaScript 35.59% GAMS 64.41%
neos-js neos optimisation operations-research gams

neos-js's Introduction

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:

npm install neos-js

Or grab a release archive file from the dist folder.

Examples

Browser: In the header include

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

then

<script type="text/javascript">
NEOS.xmlstring({
  category: 'LP',
  solver: 'CPLEX',
  inputMethod: 'GAMS',
  model: simulationModelString,
  email: '[email protected]'
})
.then(NEOS.submitJob)
.then(NEOS.getFinalResults)
.then(res => {
  // work with the resulting listing file
})
.catch(err => {
  // catch errors
})
</script>

Check out the NEOS online editor example

Node.js

const NEOS = require('neos-js')
const fs = require('fs')

// load a simulation model, in this case a GAMS file
const model = fs.readFileSync('transport_model.gms', 'utf-8')

// convert the simulation model into a NEOS XML string,
// solve and await the results
NEOS.xmlstring({
  category: 'LP',
  solver: 'CPLEX',
  inputMethod: 'GAMS',
  model: simulationModelString,
  email: '[email protected]'
})
.then(NEOS.submitJob)
.then(NEOS.getFinalResults)
.then(res => {
  // work with the resulting listing file
})
.catch(err => {
  // catch errors
})

Methods

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

Additional methods:

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.

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).

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

neos-js's People

Contributors

chrispahm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dimydisconzi

neos-js's Issues

NEOS GAMS bug

Hi, I'm with the NEOS team. We got a report about GAMS jobs not working now when submitted via neos-js. It looks like neos-js submits files with a few blank lines for the optional inputs. We recently added a feature for an optional restart file. It looks like that's causing the error because GAMS tries to restart from the blank file. If possible, it would be best if nothing is submitted for optional inputs unless there is actually information that needs to be passed in.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.