# Objective Schema

This document describes the Objective object schema returned by the globalMOO API.

## Structure

```json
{
  "id": 321,                                     // Unique identifier
  "createdAt": "2025-01-31T10:00:00.000Z",      // Creation timestamp
  "updatedAt": "2025-01-31T10:00:00.000Z",      // Last update timestamp
  "disabledAt": null,                           // Optional disable timestamp
  "optimalInverse": {                           // Optional reference to the optimal inverse solution
    "id": 456,
    // ... other inverse properties
  },
  "attemptCount": 10,                           // Number of optimization attempts
  "stopReason": 1,                              // Reason optimization stopped (enum)
  "desiredL1Norm": 0.05,                        // Desired L1 norm for optimization
  "objectives": [1500000, 850000],              // Target objective values
  "objectiveTypes": ["maximize", "minimize"],   // Type of each objective
  "minimumBounds": [1000000, 700000],           // Minimum bounds for each objective
  "maximumBounds": [2000000, 1000000],          // Maximum bounds for each objective
  "inverses": [                                 // Array of inverse optimization steps
    {
      "id": 789,
      // ... other inverse properties
    }
  ]
}
```

## Fields

| Field            | Type                                                                    | Description                                                                               |
| ---------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `id`             | integer                                                                 | Unique identifier for the objective                                                       |
| `createdAt`      | string (ISO 8601)                                                       | Timestamp when the objective was created                                                  |
| `updatedAt`      | string (ISO 8601)                                                       | Timestamp when the objective was last updated                                             |
| `disabledAt`     | string (ISO 8601) or null                                               | Timestamp when the objective was disabled, null if active                                 |
| `optimalInverse` | object or null                                                          | Reference to the optimal inverse solution, null if not found                              |
| `attemptCount`   | integer                                                                 | Number of optimization attempts made                                                      |
| `stopReason`     | integer                                                                 | Enum indicating why optimization stopped (0=Running, 1=Satisfied, 2=Stopped, 3=Exhausted) |
| `desiredL1Norm`  | number                                                                  | Desired L1 norm for the optimization process                                              |
| `objectives`     | array of numbers                                                        | Target values for each objective                                                          |
| `objectiveTypes` | array of strings                                                        | Type of each objective (exact, percent, value, lessthan, etc.)                            |
| `minimumBounds`  | array of numbers                                                        | Minimum acceptable values for each objective                                              |
| `maximumBounds`  | array of numbers                                                        | Maximum acceptable values for each objective                                              |
| `inverses`       | array of [Inverse](/globalmoo-documentation/schemas/inverse.md) objects | List of inverse optimization steps                                                        |

## Stop Reason Values

| Value | Name      | Description                                            |
| ----- | --------- | ------------------------------------------------------ |
| 0     | RUNNING   | Optimization is still running or being evaluated       |
| 1     | SATISFIED | Optimization found a satisfactory input and output     |
| 2     | STOPPED   | Optimization stopped due to duplicate suggested inputs |
| 3     | EXHAUSTED | Optimization exhausted all attempts to converge        |

## Objective Types

| Type                | Description                                                 |
| ------------------- | ----------------------------------------------------------- |
| `exact`             | Objective must be exactly the target value                  |
| `percent`           | Objective is specified as a percentage                      |
| `value`             | Objective is specified as an absolute value                 |
| `lessthan`          | Objective must be less than the target value                |
| `lessthan_equal`    | Objective must be less than or equal to the target value    |
| `greaterthan`       | Objective must be greater than the target value             |
| `greaterthan_equal` | Objective must be greater than or equal to the target value |
| `minimize`          | Objective should be minimized                               |
| `maximize`          | Objective should be maximized                               |

## SDK Representations

### JavaScript SDK

In the JavaScript SDK, the Objective object uses snake\_case naming for fields, translating from the API's camelCase:

```javascript
{
  id: 321,
  created_at: Date("2025-01-31T10:00:00.000Z"),  // Converted to Date object
  updated_at: Date("2025-01-31T10:00:00.000Z"),  // Converted to Date object
  disabled_at: null,
  optimal_inverse: null, // Will be an Inverse object if present
  attempt_count: 10,
  stop_reason: 1,
  desired_l1_norm: 0.05,
  objectives: [1500000, 850000],
  objective_types: ["maximize", "minimize"],
  minimum_bounds: [1000000, 700000],
  maximum_bounds: [2000000, 1000000],
  inverses: [
    // Inverse objects
  ],
  
  // Additional computed properties
  get iterationCount() { /* Returns number of inverses */ },
  get lastInverse() { /* Returns the last inverse in the array */ }
}
```

### Python SDK

The Python SDK also uses snake\_case naming and converts timestamps to datetime objects:

```python
Objective(
  id=321,
  created_at=datetime(2025, 1, 31, 10, 0, 0),    # Converted to datetime object
  updated_at=datetime(2025, 1, 31, 10, 0, 0),    # Converted to datetime object
  disabled_at=None,
  optimal_inverse=None,  # Will be an Inverse object if present
  attempt_count=10,
  stop_reason=StopReason.SATISFIED,  # Enum value
  desired_l1_norm=0.05,
  objectives=[1500000, 850000],
  objective_types=[ObjectiveType.MAXIMIZE, ObjectiveType.MINIMIZE],  # Enum values
  minimum_bounds=[1000000, 700000],
  maximum_bounds=[2000000, 1000000],
  inverses=[
    # Inverse objects
  ],
  
  # Properties
  @property
  def iteration_count(self): # Returns number of inverses
  
  @property
  def last_inverse(self): # Returns the last inverse in the array
)
```

### PHP SDK

The PHP SDK maintains camelCase naming to match the API and converts timestamps to DateTimeImmutable objects:

```php
Objective(
  id: 321,
  createdAt: DateTimeImmutable("2025-01-31T10:00:00.000Z"),
  updatedAt: DateTimeImmutable("2025-01-31T10:00:00.000Z"),
  disabledAt: null,
  optimalInverse: null,  // Will be an Inverse object if present
  number: 1,  // Note: PHP SDK has an additional 'number' field not in other SDKs
  attemptCount: 10,
  stopReason: StopReason::Satisfied,  // Enum value
  desiredL1Norm: 0.05,
  objectives: [1500000, 850000],
  objectiveTypes: [ObjectiveType::Maximize, ObjectiveType::Minimize],  // Enum values
  minimumBounds: [1000000, 700000],
  maximumBounds: [2000000, 1000000],
  inverses: [
    // Inverse objects
  ],
  
  // Computed properties (via __get)
  iterationCount: // Returns number of inverses
  lastInverse: // Returns the last inverse in the array
)
```

## Examples

### Optimization in Progress

```json
{
  "id": 321,
  "createdAt": "2025-01-31T10:00:00.000Z",
  "updatedAt": "2025-01-31T10:15:00.000Z",
  "disabledAt": null,
  "optimalInverse": null,
  "attemptCount": 3,
  "stopReason": 0,
  "desiredL1Norm": 0.05,
  "objectives": [1500000, 850000],
  "objectiveTypes": ["maximize", "minimize"],
  "minimumBounds": [1000000, 700000],
  "maximumBounds": [2000000, 1000000],
  "inverses": [
    {
      "id": 789,
      "createdAt": "2025-01-31T10:05:00.000Z",
      "updatedAt": "2025-01-31T10:05:00.000Z",
      "disabledAt": null,
      "inputs": [0.2, 0.3, 0.5],
      "outputs": [1300000, 900000],
      "l1Norm": 0.15
    },
    {
      "id": 790,
      "createdAt": "2025-01-31T10:10:00.000Z",
      "updatedAt": "2025-01-31T10:10:00.000Z",
      "disabledAt": null,
      "inputs": [0.25, 0.35, 0.4],
      "outputs": [1350000, 880000],
      "l1Norm": 0.12
    },
    {
      "id": 791,
      "createdAt": "2025-01-31T10:15:00.000Z",
      "updatedAt": "2025-01-31T10:15:00.000Z",
      "disabledAt": null,
      "inputs": [0.28, 0.32, 0.4],
      "outputs": [1380000, 870000],
      "l1Norm": 0.09
    }
  ]
}
```

### Completed Optimization

```json
{
  "id": 322,
  "createdAt": "2025-01-30T10:00:00.000Z",
  "updatedAt": "2025-01-30T10:30:00.000Z",
  "disabledAt": null,
  "optimalInverse": {
    "id": 795,
    "createdAt": "2025-01-30T10:25:00.000Z",
    "updatedAt": "2025-01-30T10:25:00.000Z",
    "disabledAt": null,
    "inputs": [0.3, 0.3, 0.4],
    "outputs": [1480000, 855000],
    "l1Norm": 0.048
  },
  "attemptCount": 5,
  "stopReason": 1,
  "desiredL1Norm": 0.05,
  "objectives": [1500000, 850000],
  "objectiveTypes": ["maximize", "minimize"],
  "minimumBounds": [1000000, 700000],
  "maximumBounds": [2000000, 1000000],
  "inverses": [
    // Array of Inverse objects (abbreviated for clarity)
  ]
}
```

## Related Endpoints

* [Objective Endpoints](/globalmoo-documentation/endpoints/objectives/index.md)
* [Load Objectives](/globalmoo-documentation/endpoints/objectives/load.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://globalmoo.gitbook.io/globalmoo-documentation/schemas/objective.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
