Sum of Optimization Variables NOT working

Hi, I am trying to find the sum of an optimization variable. However I am getting no output when the optimization variable contains quadratic terms. For exmaple, if I try to find the sum of an optimization array containing terms such as:
6.19*power(1, 'P_1') + 17.26*power(1, 'P_2') + 16.6*power(1, 'P_3') + 16.5*power(1, 'P_4') + 19.7*power(1, 'P_5') ...
I am able to find the sum.
However, when the array contains terms such as:
0.00048*power(1, 'P_1')^2 + 0.00031*power(1, 'P_2')^2 + 0.002*power(1, 'P_3')^2 + 0.00211*power(1, 'P_4')^2 + 0.00398*power(1, 'P_5')^2 + .........
And I attempt to find the sum, I dont get an output. Neither do I get an error message. The "ans" variable is empty.
Any help is greatly appreciated.

6 Comments

Could you post some sample code?
The problem lies with the "powerCost1" variable. "diag_quadcost" contains terms of this form:
0.00048*power(1, 'P_1')^2 + 0.00031*power(1, 'P_2')^2 + 0.002*power(1, 'P_3')^2 + 0.00211*power(1, 'P_4')^2 + 0.00398*power(1, 'P_5')^2 + .........
The "powerCost2" variable however contains the sum of terms of the following form:
6.19*power(1, 'P_1') + 17.26*power(1, 'P_2') + 16.6*power(1, 'P_3') + 16.5*power(1, 'P_4') + 19.7*power(1, 'P_5') ...
And I can find the sum of terms of this form.
But without the "powerCost1" the simulation cannot be completed.
When you talk about getting no output, is that from the call to cplexmiqp()? That is a third party toolbox from IBM.
No I am talking about this line: powerCost1 = sum(diag_quadcost, 1). This is where I get no output.
When I run the code, I got an error related to CPLEX. So I rechecked my code for errors and came across a problem with the powerCost1 variable. Although "diag_quadcost" is an array of optimization expression, when I try to find this sum of this array, I get no output. I'm assuming that because "powerCost1" has no output, the objective function will not be properly defined in the first place for CPLEX to work.
Which MATLAB release are you using?
We might need a copy of the xlsx files, just in case the problem is data-specific somehow.
I have noticed however, that I can find the sum of optimization expressions when there are no quadratic terms. This is the case for the powerCost2 variable where temp_powerCost2 is also an array of optimization expression but with NO quadratic terms. I only get the problem for powerCost1 where the optimization expressions in diag_quadcost contains quadratic terms. Not sure if this is some limitation of MATLAB?

Sign in to comment.

Categories

Asked:

on 30 Jan 2020

Answered:

on 1 Feb 2020

Community Treasure Hunt

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

Start Hunting!