-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yml
More file actions
239 lines (212 loc) · 7.28 KB
/
openapi.yml
File metadata and controls
239 lines (212 loc) · 7.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
openapi: 3.0.0
info:
# arbitrary string that specifies the version of the API
version: 0.1.0
# API name
title: AMPLRESTAPI
# Extended information about the API
description: |
AMPLRESTAPI is a custom asynchronous REST API layer written in modern Python to solve optimization problems in AMPL.
At the moment, there's a single problem available, the "Just In Time Computation" problem (JIT).
contact:
name: Alberto Schiabel
email: alberto.schiabel@gmail.com
# API server and base URL
servers:
- url: http://0.0.0.0:9001
description: Local AMPL REST server
# tags are used for organizing operations
tags:
- name: PROBLEMS
description: |
Operations that concern optimization problems
# paths define the API exposed endpoints
paths:
'/problems/jit':
post:
operationId: solvejitproblem
summary: Attempts to solve the JIT problem instance with the provided JSON input.
description: |
This operation attempts to solve the JIT problem.
The input data must be provided in JSON format.
The input should be made of the decisional variables, the fixed malus cost
and the number of programs to be computed one-at-a-time.
tags: [ 'PROBLEMS' ]
requestBody:
description: Problem decisional variables, fixed malus cost, number of batches
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/JITInput'
responses:
'200':
description: OK, return the results and some info about how AMPL and CPLEX solved the problem
content:
application/json:
schema:
$ref: '#/components/schemas/JITOutput'
'400':
$ref: '#/components/responses/BadRequestError'
'422':
$ref: '#/components/responses/UnprocessableEntityError'
components:
schemas:
# General problem meta
ProblemMeta:
type: object
properties:
iterations:
type: integer
description: number of dual simplex iterations taken by AMPL and CPLEX to compute the solution to the problem
example: 5
computation_duration:
type: number
format: float
description: amount of seconds needed to compute the solution
example: 0.016966819763183594
required:
- iterations
- computation_duration
# JIT problem input
JITDuration:
type: integer
description: Fixed duration in minutes of a program to be computed by the server
example: 5
JITDurationArray:
type: array
items:
$ref: '#/components/schemas/JITDuration'
example: [180, 360, 400, 90]
JITExpectedFinish:
type: string
format: datetime
description: Exact date and time in which the program computation is expected to finish
example: '2019-08-22 17:01'
JITExpectedFinishArray:
type: array
items:
$ref: '#/components/schemas/JITExpectedFinish'
example: ['2019-08-22 17:01', '2019-08-22 22:55', '2019-08-23 09:35', '2019-08-23 18:00']
JITWrongTimeFee:
type: integer
description: Fixed cost (in dollars) that must be payed for each minute of early or delayed computations
example: 750
JITNumberOfBatches:
type: integer
description: |
Number of programs to be processed by the server.
This parameter is used to validate the length of the array of durations and expected finish datetimes.
example: 4
JITInput:
type: object
description: Input data for the JIT problem
properties:
duration:
$ref: '#/components/schemas/JITDurationArray'
expected_finish:
$ref: '#/components/schemas/JITExpectedFinishArray'
wrong_time_fee:
$ref: '#/components/schemas/JITWrongTimeFee'
n_batches:
$ref: '#/components/schemas/JITNumberOfBatches'
required:
- duration
- expected_finish
- wrong_time_fee
- n_batches
# JIT problem output
JITTotalFee:
type: integer
description: Amount of dollars to pay due to computations finished either early or too late
example: 4500
JITStartDatetime:
type: string
format: datetime
description: Date and time in which the server actually starts the computation of a program
example: '2019-08-22 13:55'
JITStartDatetimeArray:
type: array
items:
$ref: '#/components/schemas/JITStartDatetime'
example: ['2019-08-22 13:55', '2019-08-22 21:55', '2019-08-23 18:55', '2019-08-24 17:30']
JITDeltaTime:
type: integer
description: Amount of minutes either late or early for a single program to be computed
example: 4
JITDeltaTimeArray:
type: array
items:
$ref: '#/components/schemas/JITDeltaTime'
example: [6, 0, 0, 0]
JITOutputData:
type: object
properties:
total_fee:
$ref: '#/components/schemas/JITTotalFee'
start_datetime:
$ref: '#/components/schemas/JITStartDatetimeArray'
delta_time:
$ref: '#/components/schemas/JITDeltaTimeArray'
required:
- total_fee
- start_datetime
- delta_time
JITOutput:
type: object
properties:
data:
$ref: '#/components/schemas/JITOutputData'
meta:
$ref: '#/components/schemas/ProblemMeta'
required:
- data
- meta
responses:
# Errors
BadRequestError:
description: Bad Request Error, could not parse the input data of the current request
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: 'Error type indication'
example: 'Bad request'
description:
type: string
description: 'General description of the class of errors known as "Bad Request"'
example: 'The server isn''t able to parse the given input'
details:
type: string
description: 'Hint of which problem caused the error'
example: 'Expecting '','' delimiter'
required:
- error
- description
- details
UnprocessableEntityError:
description: Unprocessable Entity Error, the input data isn't semantically valid.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: 'Error type indication'
example: 'Unprocessable entity'
description:
type: string
description: 'General description of the class of errors known as "Unprocessable Entity"'
example: 'The server understands the structure of the given input, but its semantics is invalid'
details:
type: string
description: 'Hint of which problem caused the error'
example: 'The length of the `duration` and `expected_finish` lists must equal the value of `n_batches`'
required:
- error
- description
- details