How to deal with problems where variables are not in constraints?

57 views
Skip to first unread message

JUDGE CN

unread,
Apr 30, 2019, 10:20:24 PM4/30/19
to YALMIP
Dear Prof. Johan Löfberg ,
         I have been trying a simple problem, but I have a problem which cannot be handled by yalmip.
The model is constructed as follows,

pi1=sdpvar(pi1N,1);
pi2=sdpvar(pi2N,1);
pi3=sdpvar(pi3N,1);
n=sdpvar(3,72);
m=sdpvar(1,72);

Constraints=[];
Objective=0;
C=zeros(312,1);

for i=1:72
    C=C+(Q(i,:))'*n(1,i)+(Q(i+72,:))'*n(2,i)+(Q(i+72+72,:))'*n(3,i);
end
Constraints=[Constraints, C+D'*pi1+E'*pi2+M'*pi3<=dt'];
Constraints=[Constraints, pi1<=0];
for i=1:72
    Constraints=[Constraints, norm(n(:,i),2)<=m(:,i)];
end

Objective=Objective+f'*pi1+g'*pi2+l'*pi3;
optimize(Constraints,-Objective);

My question is that variable C cannot enter the constraint during the optimization process.What do I need to do with this situation?

I will be appicated if you could help me.
best regards,
JUDGE

Johan Löfberg

unread,
May 1, 2019, 2:28:49 AM5/1/19
to YALMIP
I have no idea what you are talking about.C (i.e n) is obviously in the constraints in your model

JUDGE CN

unread,
May 1, 2019, 4:19:19 AM5/1/19
to YALMIP
Thank you for your reply. As for your doubts, I will explain as follows.

for i=1:72
    C=C+(Q(i,:))'*n(1,i)+(Q(i+72,:))'*n(2,i)+(Q(i+72+72,:))'*n(3,i);
end

You said that C is obviously within the constraint, but you look at the above formula, n is a variable.

In the optimization process, how the C constructed by n participates in the optimization.
Constructed like this, the problem is infeasible.

Johan Löfberg

unread,
May 1, 2019, 5:21:29 AM5/1/19
to YALMIP
n is a variable, C depends on n,  C is added to the constraints, I don't see what you are trying to convey.

Your problem is infeasible, but I don't see how that is related to your statements, and how should we be able to understand why your model happens to be infeasible?

JUDGE CN

unread,
May 3, 2019, 4:48:20 AM5/3/19
to YALMIP
Thank you very much for your reply. It may be that my expression is unclear and leads to your confusion.

I think that in this optimization problem, only Constraints participates in the optimization as a constraint. In statement optimize(Constraints,-Objective);, will C optimizes in real time?If not, how do I need to modify it?

The source file is as follows, thank you for your answer.
SOCP_4node.m

Johan Löfberg

unread,
May 3, 2019, 6:17:10 AM5/3/19
to YALMIP
Still don't see what the question is. C (i.e. n) is in the constraints, hence the variable n is part of the model and will be optimized

JUDGE CN

unread,
May 6, 2019, 4:50:45 AM5/6/19
to YALMIP
Hi,
I have attached my code. I use matlab and yalmip.The results are as follows:

Optimize a model with 1008 rows, 1200 columns and 2424 nonzeros
Model has 72 quadratic constraints
Coefficient statistics:
  Matrix range     [4e-05, 2e+00]
  QMatrix range    [1e+00, 1e+00]
  Objective range  [2e-03, 1e+00]
  Bounds range     [0e+00, 0e+00]
  RHS range        [7e+06, 2e+07]
Presolve removed 720 rows and 456 columns
Presolve time: 0.01s
Presolved: 288 rows, 744 columns, 1344 nonzeros
Presolved model has 72 second-order cone constraints
Ordering time: 0.00s

Barrier statistics:
 Free vars  : 192
 AA' NZ     : 7.920e+02
 Factor NZ  : 1.872e+03
 Factor Ops : 1.560e+04 (less than 1 second per iteration)
 Threads    : 1

                  Objective                Residual
Iter       Primal          Dual         Primal    Dual     Compl     Time
   0   7.25995526e+08 -1.10068465e+01  4.25e-09 1.32e+00  1.65e+07     0s
   1  -2.59840368e+08 -3.75174524e+06  6.89e-08 4.39e-01  4.78e+06     0s
   2  -6.39896649e+09 -4.04296750e+05  5.89e-06 2.65e-01  2.50e+06     0s
   3  -1.63071569e+11 -2.12078282e+06  1.33e-03 2.34e-01  7.82e+06     0s
   4  -2.68002412e+12 -1.82577532e+06  2.24e-02 2.31e-01  3.61e+07     0s
   5  -4.73360221e+12 -7.61319269e+05  2.65e+00 2.28e-01  6.11e+07     0s
   6  -1.85866448e+13 -5.83684236e+04  1.24e+01 2.29e-01  2.21e+08     0s
   7  -3.07587546e+13 -1.58549419e+04  5.27e-01 4.94e-01  7.04e+07     0s
   8  -3.89915836e+13 -4.45732644e+03  1.33e-01 5.08e-01  2.48e+07     0s
   9  -4.16106987e+13 -1.18869509e+02  1.18e-01 6.32e-01  9.89e+05     0s
  10  -5.41461836e+13 -1.10781066e+02  6.58e-01 7.31e-01  1.33e+06     0s
  11  -6.05313796e+13 -2.71236916e-01  5.93e-01 7.40e-01  2.23e+05     0s
  12  -7.30703780e+13 -1.19477957e+00  6.06e+00 7.41e-01  5.23e+04     0s
  13  -7.47555950e+13 -7.47485523e-01  5.33e+00 7.38e-01  2.32e+05     0s
  14  -8.72944913e+13 -4.38598183e-02  9.20e-01 7.40e-01  3.01e+03     0s
  15  -8.84015160e+13 -4.36246241e-02  8.36e-01 7.38e-01  1.76e+04     0s
  16  -9.06768892e+13 -2.68184508e-02  6.91e-01 7.30e-01  2.07e+04     0s
  17  -9.30351561e+13 -1.15015411e-02  5.60e-01 6.76e-01  2.69e+04     0s
  18  -9.86895283e+13 -8.07436393e-03  3.36e-01 5.90e-01  2.45e+05     0s
  19  -1.04338889e+14 -6.30817545e-03  1.98e+00 6.09e-01  2.08e+05     0s
  20  -1.12792894e+14 -1.48078871e-03  5.85e-01 6.91e-01  7.36e+04     0s
  21  -1.21572141e+14 -2.58323986e-04  2.58e-01 7.15e-01  2.52e+04     0s
  22  -1.29076202e+14 -1.11631309e-05  1.13e-01 5.97e-01  1.23e+04     0s
  23  -1.34738231e+14 -1.00771043e-05  5.29e-02 5.47e-01  9.43e+04     0s
  24  -1.47279615e+14  1.58855446e-05  4.85e+00 5.61e-01  9.13e+03     0s
  25   3.76637491e+11  0.00000000e+00  6.91e+31 1.00e+03  1.81e+34     0s

Barrier performed 25 iterations in 0.12 seconds
Numerical trouble encountered

But I don't know where the problem is?

Thanks




SOCP_4node.m

Johan Löfberg

unread,
May 6, 2019, 5:25:35 AM5/6/19
to YALMIP
Undefined function or variable 'mdiag'.
 

JUDGE CN

unread,
May 6, 2019, 6:42:18 AM5/6/19
to YALMIP
Defined in MATLAB, explained as follows:

mdiag
   m = mdiag(a1,a2,...)
 
   Forms the block-diagonal matrix
             [ a1  0  .. 0 ]
             [ 0  a2     : ]
        M =  [ :         0 ]
             [ 0  ..  0 an ]
   The number of input arguments is limited to 10.

Johan Löfberg

unread,
May 6, 2019, 6:49:15 AM5/6/19
to YALMIP
There is no such command in MATLAB, sounds like something you've hacked up.

However, it looks like you simply reinvented a limited version of blkdiag

Johan Löfberg

unread,
May 6, 2019, 6:56:43 AM5/6/19
to YALMIP
Using blkdiag as I guess that is what you mean, mosek easily finds this problem to be unbounded (which the iteration display indicates in your solve too, although that solver doesn't dare to draw that conclusion but simply says numerical problems)

Elements of both n and m can tend to infinity leading to arbitrarily good objective

JUDGE CN

unread,
May 6, 2019, 7:42:32 AM5/6/19
to YALMIP
Thank you very much for your patience, the problem has been resolved
Reply all
Reply to author
Forward
0 new messages