As for question 2), a sample code that uses om.add_quad_cost several times is
provided as follows:
for i = 1 : N
om.add_quad_cost(['c', num2str(i)], Q{i}, c{i}, 0, {'Pg','Vm'});
end
where Q{i} is negative definite.
At 2023-04-07 11:08:06, "seuyxw" <[email protected]> wrote:
Dear all,
I am trying to use callback functions in the formulation stage to consider a
user-defined quadratic objective. Specifically, my objective function does not
consider the generation cost, and it only considers maximizing the Euclidean
distance between the decision variables and several given points (a detailed
expression is given in the picture below).
To realize the above goal, I set all the coefficients in mpc.gencost to 0. I
also use om.add_quad_cost function in the formulation stage to add the
quadratic function. My questions are:
1) Am I in the right way to ignore generation cost by setting all the
coefficients to 0?
2) If I use om.add_quad_cost several times in my userfcn, does it mean that the
objective is summed up sequentially? And does the Q matrix support the
negative-definite matrix? In my case, I want to maximize the Euclidean distance
and hence, the Q matrix will be negative definite.
3) Sometimes I will encounter this warning: Matrix is close to singular or
badly scaled. Results may be inaccurate. RCOND = 2.691450e-17. However, this
optimal power flow should have at least one solution because I will get one if
I simply set the objective function as 0. Do you think this warning is caused
by my objective function? And if so, does it arise from the nonconvexity of my
quadratic objective?
Any help will be appreciated. Thank you in advance.
Best,
Yuanxi Wu