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.
Capabilities
Section titled “Capabilities”- Supports LP, MILP, QP, QCP, and NLP.
- Supports continuous and discrete decision variables.
Example
Section titled “Example”Pass "gurobi" to Problem.solve() to use the Gurobi backend:
from relationalai.semantics import Float, Modelfrom relationalai.semantics.reasoners.prescriptive import Problem
m = Model("GurobiExample")
# ... model definition ...
p = Problem(m, Float)
# ... problem definition ...
p.solve("gurobi", _server_side_import=False)Licensing and enablement
Section titled “Licensing and enablement”- 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.
Version and licensing
Section titled “Version and licensing”| Detail | Info |
|---|---|
| Version | 12.0.1 |
| License | Commercial (license required) |
For license options, see the Gurobi documentation.
Required Snowflake setup
Section titled “Required Snowflake setup”To use Gurobi in the RelationalAI Native App for Snowflake, you must:
- Store your Gurobi license key in Snowflake as a secret.
- 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 SECRETCREATE NETWORK RULECREATE EXTERNAL ACCESS INTEGRATION
Do the following:
-
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_licenseTYPE = 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; -
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_ruleMODE = EGRESSTYPE = HOST_PORTVALUE_LIST = ('token.gurobi.com:443');CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION gurobi_integrationALLOWED_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; -
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.