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.