Implementation of the coding challenge at https://github.com/gem-spaas/powerplant-coding-challenge

Aurelien 43f254b810 Correct typo in README 5 lat temu
cmd 856c6de176 Initial functional API skeleton generated by go-swagger. 5 lat temu
models f5aa61144e Further specify Powerplant object in swagger for easier validation. 5 lat temu
restapi f5aa61144e Further specify Powerplant object in swagger for easier validation. 5 lat temu
spoptim 724afcf7c1 Correct a few bugs and round wind to 0.1 to ensure 0.1 multiples. 5 lat temu
.gitignore 76b1e96fee Add gitignore and implement (naive) production plan function. 5 lat temu
Dockerfile 752fb93d5b Add Dockerfile and README. 5 lat temu
README.txt 43f254b810 Correct typo in README 5 lat temu
swagger.yml f5aa61144e Further specify Powerplant object in swagger for easier validation. 5 lat temu

README.txt

This package provides a Go implementation of the coding challenge described in https://github.com/gem-spaas/powerplant-coding-challenge. It implements a slightly less-than-naive solution to the optimal production plan problem, so does not guarantee to find the global optimum. It provides a docker container spec for easy deployment.

Installation
------------

Simply use go tools:

cd $GOPATH/src
git clone https://gogs.reverservices.eu/temp/gem-spaas-coding-challenge
cd gem-spaas-coding-challenge
go get -d ./cmd/spaas-server
go install ./cmd/spaas-server

Or docker:

git clone https://gogs.reverservices.eu/temp/gem-spaas-coding-challenge
cd gem-spaas-coding-challenge
docker build -t gem-spaas .


Usage
-----

Run the server with the spaas-server binary:

$GOPATH/bin/spaas-server --port 8888
$GOPATH/bin/spaas-server --help # See other options and arguments

Or the docker container:

docker run -p 8888:8888 gem-spaas

Testing
-------

Once the server is up and running, you can test it with the following curl commands:

- payload1: curl -X POST --header 'Content-Type: application/json' -d '{"load": 480, "fuels": {"wind(%)": 60, "kerosine(euro/MWh)": 50.8, "gas(euro/MWh)": 13.4, "co2(euro/ton)": 20}, "powerplants": [{"pmin": 100, "efficiency": 0.53, "type": "gasfired", "name": "gasfiredbig1", "pmax": 460}, {"pmin": 100, "efficiency": 0.53, "type": "gasfired", "name": "gasfiredbig2", "pmax": 460}, {"pmin": 40, "efficiency": 0.37, "type": "gasfired", "name": "gasfiredsomewhatsmaller", "pmax": 210}, {"pmin": 0, "efficiency": 0.3, "type": "turbojet", "name": "tj1", "pmax": 16}, {"pmin": 0, "efficiency": 1, "type": "windturbine", "name": "windpark1", "pmax": 150}, {"pmin": 0, "efficiency": 1, "type": "windturbine", "name": "windpark2", "pmax": 36}]}' http://localhost:8888/productionplan

- payload2: curl -X POST --header 'Content-Type: application/json' -d '{"load": 480, "fuels": {"wind(%)": 0, "kerosine(euro/MWh)": 50.8, "gas(euro/MWh)": 13.4, "co2(euro/ton)": 20}, "powerplants": [{"pmin": 100, "efficiency": 0.53, "type": "gasfired", "name": "gasfiredbig1", "pmax": 460}, {"pmin": 100, "efficiency": 0.53, "type": "gasfired", "name": "gasfiredbig2", "pmax": 460}, {"pmin": 40, "efficiency": 0.37, "type": "gasfired", "name": "gasfiredsomewhatsmaller", "pmax": 210}, {"pmin": 0, "efficiency": 0.3, "type": "turbojet", "name": "tj1", "pmax": 16}, {"pmin": 0, "efficiency": 1, "type": "windturbine", "name": "windpark1", "pmax": 150}, {"pmin": 0, "efficiency": 1, "type": "windturbine", "name": "windpark2", "pmax": 36}]}' http://localhost:8888/productionplan

- payload3: curl -X POST --header 'Content-Type: application/json' -d '{"load": 910, "fuels": {"wind(%)": 60, "kerosine(euro/MWh)": 50.8, "gas(euro/MWh)": 13.4, "co2(euro/ton)": 20}, "powerplants": [{"pmin": 100, "efficiency": 0.53, "type": "gasfired", "name": "gasfiredbig1", "pmax": 460}, {"pmin": 100, "efficiency": 0.53, "type": "gasfired", "name": "gasfiredbig2", "pmax": 460}, {"pmin": 40, "efficiency": 0.37, "type": "gasfired", "name": "gasfiredsomewhatsmaller", "pmax": 210}, {"pmin": 0, "efficiency": 0.3, "type": "turbojet", "name": "tj1", "pmax": 16}, {"pmin": 0, "efficiency": 1, "type": "windturbine", "name": "windpark1", "pmax": 150}, {"pmin": 0, "efficiency": 1, "type": "windturbine", "name": "windpark2", "pmax": 36}]}' http://localhost:8888/productionplan

Roadmap
-------

The project should be enhanced with:

- the usage of a proper interior point optimizer
- taking into account CO2 prices in the production plan
- add a websocket server that pushes production plans each time the http server computed a response

Pull requests are welcome.