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

조회 수: 2 (최근 30일)
nhavt
nhavt 2021년 7월 18일
댓글: nhavt 2021년 7월 18일
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)
  댓글 수: 1
nhavt
nhavt 2021년 7월 18일
yes, this is wondeful! I didnot know this funtion. Thanks for developing this great tool!

댓글을 달려면 로그인하십시오.

추가 답변 (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