简体   繁体   中英

How to write sumation in IBM CPLEX Python API

I am new to Cplex Python APIs, but I worked with Cplex OPL, in OPL, you can easily write this objective function Max [sum C_ij*X_ij] as:

Maximize sum(i in set1,j in set2) C_ij*X_ij

if we want to use python API, we have to define it in vector format Max C*X, which C and X are both vectors of coefficients and variables respectively. So you need to make the vector format from C_ij matrix.

Is there any way to write it in matrix format like what we do in OPL?

The CPLEX Python API does not support this, but the DOcplex Modeling for Python API is similar to OPL. For a quick start to the later see the Creating a MP model in a nutshell page, and Model.sum in the reference manual.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM