SPEAR Optimization REST Interface

Send an HTTP POST request to http://SERVER:PORT/optimize for starting the optimization.

You can also use the API in your browser using the Swagger Web UI.

Please refer to the full SPEAR API specification for details (PDF or HTML).

Use the configure service for implementation-specific settings.

Get the Docker Image to run the optimization locally.

Example Request

{
	"cells": [{
			"id": "cell1",
			"machines": [
				{"id": "machine1A"},
				{"id": "machine1B"}] 
		},{
			"id": "cell2",
			"machines": [{"id": "machine2A"}]
		}],
	"task_modes": [{
			"id": "mode1",
			"machines": ["machine1A", "machine2A"],
			"power": [1.2, 1.3, 1.4, 1.5, 1.6, 1.7]
		},{
			"id": "mode2",
			"machines": ["machine1A", "machine2A"],
			"power": [1, 5, 7]
		},{
			"id": "modeWithoutPowerCurve",
			"machines": ["machine1A", "machine1B", "machine2A"],
			"power": [-0, -0, -0]
		}],
	"tasks": [{
			"id": "taskA",
			"task_modes": ["mode1", "mode2"]
		},{
			"id": "taskB",
			"task_modes": ["modeWithoutPowerCurve"]
		}],
	"products": [{
			"id": "productX",
			"tasks": {
				"taskA": 2,
				"taskB": 5
			}
		}],
	"constraints": [{
			"id": "constraint1",
			"type": "order",
			"parameter": {
				"first_task": "taskB",
				"second_task": "taskA"
			}
		},{
			"id": "constraint2",
			"type": "collision",
			"parameter": {
				"task1": "taskA",
				"task2": "taskB"
			}
		}],
	"energy_sources": [{
			"id": "solar",
			"availability": [0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
			                 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
			                 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
			                 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
			                 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]
		},{
			"id": "socket_energy",
			"price": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
			          20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
			          30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
			          40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
			          50, 50, 50, 50, 50, 50, 50, 50, 50, 50]
		}],
	"configuration": {
		"time_window": 50,
		"optimisation_weights": {
			"energy_costs": 50,
			"energy_usage": 25,
			"makespan": 25
		},
		"stop_condition": {
			"seconds": 10,
			"generations": 5000,
			"stagnation": 100
		},
		"product_requests": [{
				"product": "productX",
				"amount": 5
			}],
		"num_restarts": 3
	}
}

Example Response

{
	"cell_schedules": [{
		"cell": "cell1",
		"assignments": [{
			"machine": "machine1A",
				"task": "taskA",
				"task_mode": "mode1",
				"start": 0
			},{
				"machine": "machine1B",
				"task": "taskB",
				"task_mode": "modeWithoutPowerCurve",
				"start": 2
			}]
	}],
	"statistics": {
		"makespan": 74,
		"costs": 640,
		"energy_sources": [{
				"source": "solar",
				"consumed_power": [0, 0, 0, 1, 2, 3, 6, 9]
			},{
				"source": "socket_energy",
				"consumed_power": [7, 7, 3, 2, 1, 0, 0, 0]
			},{
				"source": "custom_source",
				"consumed_power": [1, 1, 1, 1, 1, 1, 1, 1]
			}]
	}
}