Get coefficients of variables in constraints (solver-based approach)

2 次查看(过去 30 天)
Hi there, I am currently using the Optimization Toolbox to solve a large mixed-integer linear programing problem (ILP). So, I formulated my problem using a problem-based approach. However, the current MATLAB solver "intlinprog" is quite slow for my problem. Therefore, I am switching to CPLEX solver (version 12.10). For this, I need to formulate my problem using a solver-based approach. In particurlar, I am trying to get coefficients of variables in several constraints formulated using optimizationExpression. For example, I have a following constraint,
x = optimvar('x',[10,1]);
w = 1:10
constraint1 = w*x
So, I would like to get the coefficients of variables x in constraint1 (which is w in this simple case). Would it be possible to achieve this? Thanks very much in advance!

采纳的回答

Matt J
Matt J 2021-7-18
编辑:Matt J 2021-7-18
Yes, you can use prob2struct or prob2matrices:
S=prob2matrices({x},'Constraints',w*x<=0)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by