Your First Optimization with globalMOO

This guide will take you from zero to your first working optimization in about 15 minutes. We'll create a simple but complete example that demonstrates the key features of globalMOO.

Try it interactively: Follow along with this guide in our Interactive Google Colab Notebook

What You'll Build

We'll optimize a simple function with two inputs to achieve desired outputs. This example will teach you:

  • How to set up authentication

  • How to create a model and project

  • How to run an optimization

  • How to interpret and use the results

Prerequisites

  • Python 3.10 or higher

  • A globalMOO API key (get one at https://api.globalmoo.ai/)

  • Basic Python knowledge

Step 1: Installation and Setup

  1. Install the SDK (use the appropriate package manager for your language):

  1. Create a new file and add the necessary imports and setup:

Or if you prefer to specify credentials directly:

Step 2: Define Your Function

Let's optimize a simple linear function with 3 inputs and 5 outputs:

Step 3: Create a Model and Project

Step 4: Run Initial Learning Cases

Step 5: Set Optimization Goals

Other available objective types include:

  • ObjectiveType.EXACT: Match exactly within L1 norm

  • ObjectiveType.VALUE: Match within absolute error bounds

  • ObjectiveType.LESS_THAN: Keep output below target

  • ObjectiveType.LESS_THAN_EQUAL: Keep output at or below target

  • ObjectiveType.GREATER_THAN: Keep output above target

  • ObjectiveType.GREATER_THAN_EQUAL: Keep output at or above target

  • ObjectiveType.MINIMIZE: Minimize output down to target

  • ObjectiveType.MAXIMIZE: Maximize output up to target

Step 6: Run the Optimization Loop

Complete Code

The complete code is available in the examples directory as linear_example.py.

What's Next?

Now that you have your first optimization working, you can:

  1. Try different objective types (EXACT, VALUE, LESS_THAN, etc.)

  2. Learn about different input types (integers, categories) in the tutorials

  3. Explore more complex optimization scenarios

  4. Check out the example gallery for real-world applications

Common Issues

  1. Authentication errors

    • Check your API key in .env file or credentials

    • Ensure you're using the correct base URI

  2. Optimization not converging

    • Try increasing max_iterations

    • Check if your target values are achievable

    • Consider relaxing your objective criteria

  3. Need help?

    • Contact support@globalmoo.com

    • Check our documentation at https://docs.globalmoo.ai

Last updated