All Products
Search
Document Center

Optimization Solver:Optimization Solver console SDKs

Last Updated:Apr 01, 2026

The Optimization Solver console SDKs enable you to query license information programmatically — including service activation status, purchased license details, and license usage. If your application does not need to query this information, you do not need to install the SDKs.

Supported languages

SDKs are available for Java, Python3, Go, and C++.

LanguageGitHub repositoryREADME
Javaalibabacloud-java-sdkREADME.md
Goalibabacloud-go-sdkREADME.md
Python3alibabacloud-python-sdkREADME.md
C++alibabacloud-cpp-sdkREADME.md

The following sections use Java to demonstrate all three API operations. For Go, Python3, and C++, see the README in the corresponding GitHub repository.

Prerequisites

Before you begin, ensure that you have:

  • An active Optimization Solver service

  • An AccessKey ID and AccessKey secret (see Obtain an AccessKey pair)

  • The fastjson dependency configured in your Java project (version 1.2.83)

Authentication

All examples authenticate using an AccessKey ID and AccessKey secret. Store these credentials as environment variables rather than hardcoding them in your source code — hardcoded credentials risk leakage if code is shared or committed to version control.

Use a Resource Access Management (RAM) user with the minimum required permissions instead of your Alibaba Cloud account credentials. To create a RAM user, log in to the RAM console.

The examples read credentials from the following environment variables:

Environment variableDescription
OSS_ACCESS_KEY_IDYour AccessKey ID
OSS_ACCESS_KEY_SECRETYour AccessKey secret

Java SDK examples

Add the fastjson dependency to your Maven project:

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.83</version>
</dependency>

All three examples follow the same structure: configure credentials and an endpoint, create a client, then call the target API.

Check service activation status

Use GetOpenStatus to verify whether Optimization Solver services are activated for your account.

package com.alibaba.mind.opt.sdk;

import com.alibaba.fastjson.JSON;

import com.aliyun.opt20210730.Client;
import com.aliyun.opt20210730.models.GetOpenStatusResponse;
import com.aliyun.teaopenapi.models.Config;

public class GetOpenStatusExample {

    public static void main(String[] args) {
        try {
            Config authConfig = new Config();
            authConfig.accessKeyId = System.getenv("OSS_ACCESS_KEY_ID");
            authConfig.accessKeySecret = System.getenv("OSS_ACCESS_KEY_SECRET");
            authConfig.endpoint = "opt.cn-beijing.aliyuncs.com";
            Client client = new Client(authConfig);
            GetOpenStatusResponse getOpenStatusResponse = client.getOpenStatus();
            System.out.println(JSON.toJSONString(getOpenStatusResponse.getHeaders()));
            System.out.println(JSON.toJSONString(getOpenStatusResponse.getBody()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Query purchased license information

Use GetOrderInfo to retrieve details about your purchased licenses.

Before calling the API, select values for the required parameters:

relService — the service to query:

ValueDescription
MPMathematical programming service

resourceType — the license edition:

ValueDescription
1Local Edition
package com.alibaba.mind.opt.sdk;

import com.alibaba.fastjson.JSON;

import com.aliyun.opt20210730.Client;
import com.aliyun.opt20210730.models.GetOrderInfoRequest;
import com.aliyun.opt20210730.models.GetOrderInfoResponse;
import com.aliyun.teaopenapi.models.Config;

public class GetOrderInfoExample {

    public static void main(String[] args) {
        try {
            Config authConfig = new Config();
            authConfig.accessKeyId = System.getenv("OSS_ACCESS_KEY_ID");
            authConfig.accessKeySecret = System.getenv("OSS_ACCESS_KEY_SECRET");
            authConfig.endpoint = "opt.cn-hangzhou.aliyuncs.com";
            Client client = new Client(authConfig);
            GetOrderInfoRequest request = new GetOrderInfoRequest();
            request.setRelService("MP");   // MP = mathematical programming service
            request.setResourceType(1);    // 1 = Local Edition
            GetOrderInfoResponse getOrderInfoResponse = client.getOrderInfo(request);
            System.out.println(JSON.toJSONString(getOrderInfoResponse.getHeaders()));
            System.out.println(JSON.toJSONString(getOrderInfoResponse.getBody()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Query license usage

Use GetOrderUsage to retrieve usage data for your licenses over a specified time range.

Before calling the API, select values for all three parameters:

relService — the service to query:

ValueDescription
MPMathematical programming service

resourceType — the license edition:

ValueDescription
1Local Edition

timeRange — the reporting window relative to the current date:

ValueDescription
1One day before and after today
2One week before and after today
3One month before and after today
package com.alibaba.mind.opt.sdk;

import com.alibaba.fastjson.JSON;

import com.aliyun.opt20210730.Client;
import com.aliyun.opt20210730.models.GetOrderUsageRequest;
import com.aliyun.opt20210730.models.GetOrderUsageResponse;
import com.aliyun.teaopenapi.models.Config;

public class GetOrderUsageExample {

    public static void main(String[] args) {
        try {
            Config authConfig = new Config();
            authConfig.accessKeyId = System.getenv("OSS_ACCESS_KEY_ID");
            authConfig.accessKeySecret = System.getenv("OSS_ACCESS_KEY_SECRET");
            authConfig.endpoint = "opt.cn-hangzhou.aliyuncs.com";
            Client client = new Client(authConfig);
            GetOrderUsageRequest request = new GetOrderUsageRequest();
            request.setRelService("MP");   // MP = mathematical programming service
            request.setResourceType(1);    // 1 = Local Edition
            request.setTimeRange(1);       // 1 = one day before and after today
            GetOrderUsageResponse listOrderUsage = client.getOrderUsage(request);
            System.out.println(JSON.toJSONString(listOrderUsage.getHeaders()));
            System.out.println(JSON.toJSONString(listOrderUsage.getBody()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

References