Load Objectives
Loads optimization objectives for a trial in globalMOO.
Endpoint
POST /models/{model_id}/projects/{project_id}/trials/{trial_id}/objectives
Path Parameters
model_id
integer
Yes
ID of the model
project_id
integer
Yes
ID of the project
trial_id
integer
Yes
ID of the trial
Request Parameters
objectives
array[float]
Yes
Target values for each objective
objectiveTypes
array[string]
Yes
Type for each objective (see below)
initialInput
array[float]
Yes
Initial input values (must match project input count)
initialOutput
array[float]
Yes
Initial output values (must match objectives count)
desiredL1Norm
float
Yes
Desired L1 norm for objectives (default: 0.0)
minimumBounds
array[float]
Conditional
Lower bounds (required for percent/value types)
maximumBounds
array[float]
Conditional
Upper bounds (required for percent/value types)
Objective Types
Valid objective types are:
exact
- Match target value exactly within L1 normpercent
- Within a percentage range of target value (requires bounds)value
- Within an absolute range of target value (requires bounds)lessthan
- Less than target valuelessthan_equal
- Less than or equal to target valuegreaterthan
- Greater than target valuegreaterthan_equal
- Greater than or equal to target valueminimize
- Find minimum possible valuemaximize
- Find maximum possible value
Request Format
{
"objectives": [100.0, 50.0, 25.0],
"objectiveTypes": ["percent", "value", "percent"],
"initialInput": [1.0, 2.0, 3.0],
"initialOutput": [90.0, 45.0, 20.0],
"desiredL1Norm": 0.0,
"minimumBounds": [-5.0, -2.0, -1.0],
"maximumBounds": [5.0, 2.0, 1.0]
}
Response Format
{
"id": 123,
"trialId": 456,
"objectives": [100.0, 50.0, 25.0],
"objectiveTypes": ["percent", "value", "percent"],
"initialInput": [1.0, 2.0, 3.0],
"initialOutput": [90.0, 45.0, 20.0],
"l1Norm": 0.0,
"minimumBounds": [-5.0, -2.0, -1.0],
"maximumBounds": [5.0, 2.0, 1.0],
"createdAt": "2025-01-31T10:00:00.000Z",
"updatedAt": "2025-01-31T10:00:00.000Z",
"results": [
{
"number": 0,
"type": "percent",
"objective": 100.0,
"minimumBound": null,
"maximumBound": null,
"output": 90.0,
"error": 10.0,
"detail": "Error exceeds L1 norm threshold",
"satisfied": false
},
{
"number": 1,
"type": "value",
"objective": 50.0,
"minimumBound": -2.0,
"maximumBound": 2.0,
"output": 45.0,
"error": -5.0,
"detail": "Output within absolute bounds",
"satisfied": true
}
]
}
Examples
from globalmoo import Client, ObjectiveType
client = Client(api_key="your-api-key")
objectives = client.load_objectives(
model_id=123,
project_id=456,
trial_id=789,
objectives=[100.0, 50.0, 25.0],
objective_types=[
ObjectiveType.PERCENT,
ObjectiveType.VALUE,
ObjectiveType.PERCENT
],
initial_input=[1.0, 2.0, 3.0],
initial_output=[90.0, 45.0, 20.0],
minimum_bounds=[-5.0, -2.0, -1.0],
maximum_bounds=[5.0, 2.0, 1.0]
)
# Checking detailed results
for result in objectives.results:
print(f"Objective {result.number}:")
print(f" Type: {result.type}")
print(f" Target: {result.objective}")
print(f" Output: {result.output}")
print(f" Error: {result.error}")
print(f" Satisfied: {'✓' if result.satisfied else '✗'}")
print(f" Detail: {result.detail}")
Error Responses
400
Invalid request - Missing required fields, invalid format, or validation errors
401
Unauthorized - Invalid API key
404
Model, project, or trial not found
429
Too many requests - Rate limit exceeded
500
Internal server error
Server-Side Validation
The API performs the following validations:
Model, project, and trial IDs must be positive integers
Array lengths must be consistent:
objectives and objectiveTypes must have the same length
initialInput length must match the project's input count
initialOutput length must match objectives length
minimumBounds/maximumBounds must match objectives length when required
All numeric values must be valid floating point numbers
Objective types must be valid types as listed above
For percent and value objectives:
minimumBounds and maximumBounds are required
maximumBounds values must be greater than minimumBounds
desiredL1Norm must be provided and non-negative (defaults to 0.0)
Trial must exist and be in an active state
Last updated