Преглед на файлове

Add Dockerfile and README.

Aurelien преди 5 години
родител
ревизия
752fb93d5b
променени са 2 файла, в които са добавени 61 реда и са изтрити 0 реда
  1. 8 0
      Dockerfile
  2. 53 0
      README.txt

+ 8 - 0
Dockerfile

@@ -0,0 +1,8 @@
+FROM golang:1.15.6-alpine3.12
+RUN apk add --no-cache git
+RUN mkdir /go/src/gem-spaas-coding-challenge
+ADD . /go/src/gem-spaas-coding-challenge
+WORKDIR /go/src/gem-spaas-coding-challenge
+RUN go get -d ./cmd/spaas-server
+RUN go build -o spaas-server ./cmd/spaas-server
+CMD ["/go/src/gem-spaas-coding-challenge/spaas-server", "--host", "0.0.0.0", "--port", "8888"]

+ 53 - 0
README.txt

@@ -0,0 +1,53 @@
+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 .
+  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.