Skip to content

Commit

Permalink
rename objective function service to objective evaluation service
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Sep 21, 2022
1 parent c8ebf59 commit ebecb0a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ jobs:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push latest of objective function service
- name: Build and push latest of objective evaluation service
if: ${{ steps.vars.outputs.tag == 'main' }}
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: planqk/objective-function-service:latest
tags: planqk/objective-evaluation-service:latest

- name: Build and push version of objective function service
- name: Build and push version of objective evaluation service
if: ${{ steps.vars.outputs.tag != 'main' }}
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: planqk/objective-function-service:${{ steps.vars.outputs.tag }}
tags: planqk/objective-evaluation-service:${{ steps.vars.outputs.tag }}
Binary file modified README.md
Binary file not shown.
20 changes: 10 additions & 10 deletions app/controller/objectiveFns/objective_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from app.services import objective_service
from app.model.objective_response import ObjectiveResponseSchema
from app.model.objective_request import (
TSPObjectiveFunctionRequest,
TSPObjectiveFunctionRequestSchema,
MaxCutObjectiveFunctionRequest,
MaxCutObjectiveFunctionRequestSchema,
TSPObjectiveEvaluationRequest,
TSPObjectiveEvaluationRequestSchema,
MaxCutObjectiveEvaluationRequest,
MaxCutObjectiveEvaluationRequestSchema,
)


Expand All @@ -20,7 +20,7 @@

@blp.route("/tsp", methods=["POST"])
@blp.arguments(
TSPObjectiveFunctionRequestSchema,
TSPObjectiveEvaluationRequestSchema,
example=dict(
adj_matrix=[[0, 1, 1, 0], [1, 0, 1, 1], [1, 1, 0, 1], [0, 1, 1, 0]],
counts={"1" * 16: 100, "0" * 16: 100},
Expand All @@ -29,17 +29,17 @@
),
)
@blp.response(200, ObjectiveResponseSchema)
def tsp(json: TSPObjectiveFunctionRequest):
def tsp(json: TSPObjectiveEvaluationRequest):
print(json)
if json:
return objective_service.generate_tsp_objective_response(
TSPObjectiveFunctionRequest(**json)
TSPObjectiveEvaluationRequest(**json)
)


@blp.route("/max-cut", methods=["POST"])
@blp.arguments(
MaxCutObjectiveFunctionRequestSchema,
MaxCutObjectiveEvaluationRequestSchema,
example={
"adj_matrix": [
[0, 3, 3, 6, 9, 1],
Expand All @@ -61,9 +61,9 @@ def tsp(json: TSPObjectiveFunctionRequest):
},
)
@blp.response(200, ObjectiveResponseSchema)
def max_cut(json: MaxCutObjectiveFunctionRequest):
def max_cut(json: MaxCutObjectiveEvaluationRequest):
print(json)
if json:
return objective_service.generate_max_cut_objective_response(
MaxCutObjectiveFunctionRequest(**json)
MaxCutObjectiveEvaluationRequest(**json)
)
8 changes: 4 additions & 4 deletions app/model/objective_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np


class TSPObjectiveFunctionRequest:
class TSPObjectiveEvaluationRequest:
def __init__(
self, adj_matrix, counts, objFun, objFun_hyperparameters={}, visualization=False
):
Expand All @@ -14,7 +14,7 @@ def __init__(
self.objFun_hyperparameters = objFun_hyperparameters


class TSPObjectiveFunctionRequestSchema(ma.Schema):
class TSPObjectiveEvaluationRequestSchema(ma.Schema):
adj_matrix = ma.fields.List(ma.fields.List(ma.fields.Float()), required=True)
counts = ma.fields.Dict(
keys=ma.fields.Str(), values=ma.fields.Float(), required=True
Expand All @@ -24,7 +24,7 @@ class TSPObjectiveFunctionRequestSchema(ma.Schema):
objFun_hyperparameters = ma.fields.Dict(keys=ma.fields.Str(), required=False)


class MaxCutObjectiveFunctionRequest:
class MaxCutObjectiveEvaluationRequest:
def __init__(
self, adj_matrix, counts, objFun, objFun_hyperparameters={}, visualization=False
):
Expand All @@ -35,7 +35,7 @@ def __init__(
self.objFun_hyperparameters = objFun_hyperparameters


class MaxCutObjectiveFunctionRequestSchema(ma.Schema):
class MaxCutObjectiveEvaluationRequestSchema(ma.Schema):
adj_matrix = ma.fields.List(ma.fields.List(ma.fields.Float()))
counts = ma.fields.Dict(keys=ma.fields.Str(), values=ma.fields.Float())
objFun = ma.fields.Str()
Expand Down
4 changes: 2 additions & 2 deletions app/model/objective_response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime
import marshmallow as ma
from .objective_request import TSPObjectiveFunctionRequestSchema
from .objective_request import TSPObjectiveEvaluationRequestSchema


class ObjectiveResponse:
Expand All @@ -24,5 +24,5 @@ def to_json(self):
class ObjectiveResponseSchema(ma.Schema):
objective_value = ma.fields.Float()
visualization = ma.fields.String()
input = ma.fields.Nested(TSPObjectiveFunctionRequestSchema)
input = ma.fields.Nested(TSPObjectiveEvaluationRequestSchema)
timestamp = ma.fields.String()
8 changes: 4 additions & 4 deletions app/services/objective_service.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from app.model.objective_request import (
TSPObjectiveFunctionRequest,
MaxCutObjectiveFunctionRequest,
TSPObjectiveEvaluationRequest,
MaxCutObjectiveEvaluationRequest,
)
from app.model.objective_response import ObjectiveResponse
from app.services.objectiveFunctions import F_CVaR, F_EE, F_Gibbs
from app.services.visualization import TspVisualization, MaxCutVisualization
from app.constants import *


def generate_tsp_objective_response(input: TSPObjectiveFunctionRequest):
def generate_tsp_objective_response(input: TSPObjectiveEvaluationRequest):
objective_function = getObjectiveFunction(
input.objFun, TSP, **input.objFun_hyperparameters
)
Expand All @@ -25,7 +25,7 @@ def generate_tsp_objective_response(input: TSPObjectiveFunctionRequest):
return ObjectiveResponse(objective_value, graphic, input)


def generate_max_cut_objective_response(input: MaxCutObjectiveFunctionRequest):
def generate_max_cut_objective_response(input: MaxCutObjectiveEvaluationRequest):
objective_function = getObjectiveFunction(
input.objFun, MAX_CUT, **input.objFun_hyperparameters
)
Expand Down

0 comments on commit ebecb0a

Please sign in to comment.