- Python (>3.5)
- Pip
- Should come pre-installed with Python 3.5.
- Flask
- Flask-Socketio
- Pymzn
- Minizinc
- http://www.minizinc.org/software.html
- Easiest method: grab the bundled binary package and add the folder to your environment variables/PATH.
- Assuming you have python and pip installed, run the following two commands in your cmd/terminal window:
pip install flask
pip install flask-socketio
pip install pymzn
- After you have the dependencies installed, in order for Flask to run it needs to know what the server file is called.
- The environment variable
FLASK_APP
needs to be set. To do this:- Windows:
set FLASK_APP=server.py
- Mac OSX/Linux:
export FLASK_APP=server.py
- Windows:
- The environment variable
- In your terminal window, run
flask run
to start the server. - The server should be hosted on port 5000, by default at http://localhost:5000.
NOTE: The REST API is formatted a little bit weirdly at the moment (not akin to a real REST API) this will be fixed in the future).
The MiniZinc server solves certain MiniZinc files on the backend and returns the output. All the following URLs will be relative to the root URL, i.e. the REST api is accessed by appending certain URLs like /models/queens
to localhost:5000
.
.mzn
model files must not have any output format defined, nor have any parameters with values set prior to being run by the server.
Returns the MiniZinc model files available in the server.
- No parameters.
{
"models": [
"queens.mzn",
"schedule.mzn",
"test.mzn",
"test2.mzn"
]
}
Returns the input arguments for the specified Minizinc model.
<modelName>
: the name of the MiniZinc model (required).
{
"capacity": "array(int)",
"consumption": "array(int)",
"nproducts": "int",
"nresources": "int",
"pname": "array(string)",
"profit": "array(int)",
"rname": "array(string)"
}
Solves the input MiniZinc model file in the backend and outputs in JSON. Add extra parameters by using ?<parameterName>=<result>
.
E.g. localhost:5000/solve/exampleModel?arg1=ex1&arg2=ex2
<modelName>
: the name of the MiniZinc model (required).
Solves the input MiniZinc model file in the backend and streams each solution as it comes.
<modelName>
: the name of the MiniZinc model (required).n
: number of Queens to solve. (only applicable to Queens at the moment). (required)