Skip to content

This feature is currently in Preview.

Use Gurobi

Choose Gurobi as your solver backend when you need a commercial-grade solver for large or hard optimization problems. Compared to HiGHS, it supports more problem classes (including QCP and NLP) and often performs better on hard MILPs.

  • Supports LP, MILP, QP, QCP, and NLP.
  • Supports continuous and discrete decision variables.

Pass "gurobi" to Problem.solve() to use the Gurobi backend:

from relationalai.semantics import Float, Model
from relationalai.semantics.reasoners.prescriptive import Problem
m = Model("GurobiExample")
# ... model definition ...
p = Problem(m, Float)
# ... problem definition ...
p.solve("gurobi", _server_side_import=False)
  • Gurobi requires a valid license.
  • In managed and Snowflake deployments, Gurobi typically must be enabled at the deployment or instance level. If you do not have access, ask your administrator.
DetailInfo
Version12.0.1
LicenseCommercial (license required)

For license options, see the Gurobi documentation.

To use Gurobi in the RelationalAI Native App for Snowflake, you must:

  1. Store your Gurobi license key in Snowflake as a secret.
  2. Allow the app to reach Gurobi’s license server (token.gurobi.com:443) using an external access integration.

You typically need the following Snowflake privileges to complete setup:

  • CREATE SECRET
  • CREATE NETWORK RULE
  • CREATE EXTERNAL ACCESS INTEGRATION

Do the following:

  1. Store the license key in Snowflake

    Choose a database and schema to store the secret (or reuse an existing location):

    CREATE DATABASE IF NOT EXISTS solvers;
    CREATE SCHEMA IF NOT EXISTS solvers.secrets;

    Create the secret. Preserve whitespace and line breaks in the license key string:

    CREATE SECRET IF NOT EXISTS solvers.secrets.gurobi_license
    TYPE = generic_string
    -- Replace <MY_GUROBI_LICENSE_KEY> with your actual Gurobi license key.
    -- IMPORTANT: Make sure you preserve the whitespace and line breaks.
    SECRET_STRING = '<MY_GUROBI_LICENSE_KEY>';
    GRANT USAGE ON DATABASE solvers TO APPLICATION RELATIONALAI;
    GRANT USAGE ON SCHEMA solvers.secrets TO APPLICATION RELATIONALAI;
    GRANT READ ON SECRET solvers.secrets.gurobi_license TO APPLICATION RELATIONALAI;
  2. Allow the app to authenticate the license

    Create a schema to store the network rule (or reuse an existing location):

    CREATE SCHEMA IF NOT EXISTS solvers.networking;

    Create the network rule and external access integration:

    CREATE OR REPLACE NETWORK RULE solvers.networking.gurobi_network_rule
    MODE = EGRESS
    TYPE = HOST_PORT
    VALUE_LIST = ('token.gurobi.com:443');
    CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION gurobi_integration
    ALLOWED_NETWORK_RULES = (solvers.networking.gurobi_network_rule)
    ENABLED = true;
    GRANT USAGE ON SCHEMA solvers.networking TO APPLICATION RELATIONALAI;
    GRANT USAGE ON INTEGRATION gurobi_integration TO APPLICATION RELATIONALAI;
  3. Enable Gurobi for your app instance

    Access to the Gurobi license is typically granted at the RAI Native App instance level. After you create the secret and the external access integration, you usually need an administrator (or RelationalAI support) to enable the Gurobi backend for the app instance using the secret and integration names you created.

    If you need multiple Gurobi licenses, provision them by repeating the setup with separate secrets and integrations.

  • solve("gurobi", ...) fails immediately if the license and configuration are missing.