# Running time of cvx problem

(zhangQK) #1

cf=3.7;ce=0.8;rho22=0.717;Qb=180;
Rint=R_int_dis(20:92);Voc_sig=Voc_sig_dis(20:92);
soc1=linspace(0,1,100)’;soc=soc1(20:92);
SOC0=0.8;SOCf=0.3;
SOCmax=0.9;SOCmin=0.2;
pp=polyfit(soc,Voc_sig,1);
PEGU1=linspace(9,87,100)’;
aaa=interp1(Pegu3,b10,PEGU1);
mf=interp1(Pegu3,b10,PEGU1).PEGU1/3600/1000/rho22;
pppp=polyfit(PEGU1,mf,2);
nb=168;
Pon=45;
et=zeros(length(y1),1);
Imin=-50;Imax=90;
Ueding=537.6/168;
C=2
Qb/Ueding;
R=6.523110^(-4);
aa=3600
RQb/pp(1);bb=2000RC;
et(find(Pr>Pon))=1;
cvx_solver SeDuMi
cvx_begin
variable PEGU(length(y1));
variable PB(length(y1));
variable E(length(y1)+1);
expression Vqihao(length(y1));
Vqihao=pppp(1)PEGU.^2+pppp(2)PEGU+pppp(3)et;
minimize(sum(cf
Vqihao)+ce
(SOC0-SOCf)QbUeding
nb/1000);
subject to
E(1)==C/2
nb*(pp(1)SOC0+pp(2))^2;
E(length(y1)+1)==C/2
nb*(pp(1)SOCf+pp(2))^2;
E(length(y1))==C/2
nb*(pp(1)SOCf+pp(2))^2;
PEGU(find(et==0))==0;
Pr<=PB+PEGU;
0<=PEGU<=87;
(Imin
(2E(1:length(y1))/Cnb).^0.5-RImin^2nb)/1000<=PB<=E(1:length(y1))/2/R/C/1000;
1000RCPB-(ImaxR)^2Cnb-ImaxR(2Cnb)^0.5*(E(1:length(y1))-2000RCPB).^0.5<=0;
C/2
nb*(pp(1)SOCmin+pp(2))^2<=E<=C/2nb*(pp(1)SOCmax+pp(2))^2;
for j=1:length(y1)
{aa
(E(j+1)-E(j))+E(j),E(j),E(j)-bb*PB(j)}==rotated_lorentz(1);
end
cvx_end

In this problem,because length(y1) is 19710, when cvx runs the section called
’ for j=1:length(y1) %length(y1)=19710
{aa*(E(j+1)-E(j))+E(j),E(j),E(j)-bb*PB(j)}==rotated_lorentz(1);
end ', it will cost lots of time(more than 40 minutes).
So I want to know how to deal with this problem so that running time can reduce largely.
Thank you.

(Mark L. Stone) #2

Vector variable `PEGU` having length of 19710, which is the length of `y1`, seems to be popular on this forum Out of memory. Type HELP MEMORY for your options . It would be better to keep follow on questions on the same topic in the same thread.

As for avoiding the for loop, so as to speed things up, as I wrote at Rotated_lorentz

I don’t know of a way to do that without a loop. If someone else does, please post it.

However in YALMIP, the `cone` command can be used in a vectorized (matrix) fashion to accomplish this. That should makes things much faster.

(zhangQK) #3

Thank you,Mark.
Could you give me an example about the `cone` command in YALMIP for '{aa*(E(j+1)-E(j))+E(j),E(j),E(j)-bb*PB(j)}==rotated_lorentz(1) '.

(Mark L. Stone) #4

You can read https://yalmip.github.io/command/cone/ and search for examples on https://groups.google.com/forum/#!forum/yalmip , where YALMIP questions should be addressed.

(zhangQK) #5

Hi,Mark.I meet a problem when I run the program.
In the program,there is a constraint called ’ *0<=PEGU<=87;’. But after running the program, the value of PEGU appears negative number.
So I want to know why variables (PEGU,PB and E) are sometimes not in constraints.

cvx_status is ‘Solved’.

(Erling D.Andersen) #6

How negative is the variable?

What about posting the log output.

(zhangQK) #7

Negative numbers of PEGU are about -2.
In addition, the values of PEGU and PB do sometimes not follow the constraint called
‘Pr<=PB+PEGU’ (the values of Pr are known.).

(Mark L. Stone) #8

Please show the output from `cvx_version`. As I warned you at Out of memory. Type HELP MEMORY for your options , “CVX 3.0beta is very buggy, so it may not work at all, or even if it claims to find the optimal solution, it could be wrong.” and " I will warn again though that due to the bugginess of CVX 3.0beta, it is possible that the solver was not even provided the correct constraints for the problem."

Are you able to get this to run under CVX 2.1?

Show your program, complete with all input data if possible, and show all CVX and solver output. And show your MATLAB calculations demonstrating the constraint violations.

Have you tried other solvers?

(zhangQK) #9

## Calling SeDuMi 1.34: 394202 variables, 100469 equality constraints For improved efficiency, SeDuMi is solving the dual problem.

SeDuMi 1.34 (beta) by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 100469, order n = 315363, dim = 394203, blocks = 78841
nnz(A) = 484550 + 0, nnz(ADA) = 387917, nnz(L) = 244193
it : by gap delta rate t/tP t/tD* feas cg cg prec
0 : 2.97E+03 0.000
1 : -1.77E+06 2.41E+03 0.000 0.8105 0.9000 0.9000 7.83 2 1 1.8E+02
2 : -3.75E+05 2.33E+03 0.000 0.9677 0.9000 0.9000 69.92 2 2 3.2E+01
3 : -2.58E+05 6.60E+01 0.000 0.0283 0.9000 0.0046 141.06 2 2 3.7E-01
4 : 7.40E+04 5.32E-11 0.000 0.0000 0.2105 0.9000 8.74 2 2 7.1E-02
5 : 1.79E+04 7.32E-12 0.000 0.1377 0.9264 0.9000 9.89 2 2 2.8E-03
6 : 1.10E+04 1.28E-12 0.000 0.1746 0.9000 0.1927 2.65 1 2 6.2E-04
7 : 2.66E+03 2.41E-13 0.000 0.1885 0.9049 0.9000 1.77 1 1 8.5E-05
8 : 1.05E+03 8.61E-14 0.211 0.3571 0.9408 0.9000 2.20 1 2 1.9E-05
9 : 3.11E+02 3.82E-14 0.000 0.4440 0.9000 0.9226 1.94 2 2 5.6E-06
10 : 8.42E+01 1.15E-14 0.000 0.3018 0.9000 0.9043 1.68 2 2 1.2E-06
11 : 3.95E+01 3.72E-15 0.000 0.3221 0.9069 0.9000 1.38 2 2 3.2E-07
12 : 2.99E+01 1.77E-15 0.000 0.4763 0.9042 0.9000 1.24 2 2 1.3E-07
13 : 2.84E+01 1.44E-15 0.000 0.8142 0.0644 0.9000 1.13 2 2 1.1E-07
14 : 2.80E+01 1.33E-15 0.000 0.9213 0.7042 0.9000 1.08 2 2 9.0E-08
15 : 2.77E+01 1.25E-15 0.000 0.9417 0.9000 0.9815 0.37 3 3 8.6E-08
16 : 2.75E+01 1.19E-15 0.000 0.9519 0.9000 0.9596 0.04 3 3 8.4E-08
17 : 2.72E+01 1.11E-15 0.095 0.9368 0.9000 0.9506 0.38 3 3 7.9E-08
18 : 2.71E+01 1.09E-15 0.000 0.9755 0.9104 0.9000 0.38 3 3 7.8E-08
19 : 2.70E+01 1.05E-15 0.000 0.9633 0.9000 0.9624 0.07 3 3 7.7E-08
20 : 2.69E+01 1.01E-15 0.000 0.9667 0.9000 0.9501 -0.04 3 3 7.5E-08
21 : 2.69E+01 9.95E-16 0.000 0.9827 0.9000 0.9000 0.09 3 3 7.5E-08
22 : 2.67E+01 9.65E-16 0.000 0.9695 0.9000 0.9000 0.34 3 3 7.3E-08
23 : 2.65E+01 8.95E-16 0.000 0.9273 0.9000 0.9068 0.40 3 3 6.9E-08
24 : 2.64E+01 8.68E-16 0.036 0.9697 0.9000 0.9625 0.11 3 3 6.7E-08
25 : 2.63E+01 8.38E-16 0.000 0.9661 0.9000 0.9525 -0.11 3 3 6.6E-08
26 : 2.62E+01 8.11E-16 0.000 0.9668 0.9000 0.9489 -0.13 3 3 6.5E-08
27 : 2.61E+01 7.82E-16 0.000 0.9650 0.9010 0.9000 -0.04 3 3 6.4E-08
28 : 2.60E+01 7.54E-16 0.000 0.9637 0.9000 0.9575 -0.14 3 3 6.3E-08
29 : 2.59E+01 7.27E-16 0.000 0.9643 0.9000 0.9482 -0.18 3 3 6.2E-08
30 : 2.58E+01 7.02E-16 0.000 0.9656 0.9000 0.9451 -0.17 3 3 6.1E-08
31 : 2.57E+01 6.77E-16 0.000 0.9643 0.9000 0.9475 -0.20 3 3 6.0E-08
32 : 2.56E+01 6.48E-16 0.000 0.9572 0.9000 0.9490 -0.29 3 3 5.9E-08
33 : 2.55E+01 6.21E-16 0.000 0.9588 0.9000 0.9447 -0.31 3 3 5.8E-08
34 : 2.55E+01 5.98E-16 0.000 0.9631 0.9000 0.9393 -0.22 3 3 5.7E-08
35 : 2.54E+01 5.77E-16 0.000 0.9638 0.9000 0.9381 -0.21 3 3 5.6E-08
36 : 2.53E+01 5.56E-16 0.000 0.9640 0.9000 0.9391 -0.19 3 3 5.5E-08
37 : 2.52E+01 5.37E-16 0.000 0.9656 0.9000 0.9432 -0.16 3 3 5.4E-08
38 : 2.51E+01 5.16E-16 0.000 0.9618 0.9105 0.9000 -0.02 3 3 5.3E-08
39 : 2.50E+01 4.93E-16 0.000 0.9547 0.9000 0.9559 -0.15 3 3 5.2E-08
40 : 2.49E+01 4.69E-16 0.000 0.9523 0.9000 0.9507 -0.23 3 3 5.1E-08
41 : 2.48E+01 4.49E-16 0.000 0.9574 0.9000 0.9393 -0.21 3 3 5.0E-08
42 : 2.47E+01 4.30E-16 0.000 0.9581 0.9000 0.9447 -0.17 3 3 4.9E-08
43 : 2.46E+01 4.13E-16 0.000 0.9605 0.9000 0.9368 -0.15 3 3 4.8E-08
44 : 2.45E+01 3.97E-16 0.000 0.9614 0.9000 0.9374 -0.14 3 3 4.7E-08
45 : 2.44E+01 3.80E-16 0.000 0.9570 0.9000 0.9180 -0.05 3 3 4.6E-08
46 : 2.43E+01 3.62E-16 0.000 0.9527 0.9000 0.9495 -0.16 3 3 4.5E-08
47 : 2.42E+01 3.42E-16 0.000 0.9428 0.9000 0.9495 -0.28 3 3 4.4E-08
48 : 2.41E+01 3.23E-16 0.000 0.9464 0.9000 0.9395 -0.26 3 3 4.4E-08
49 : 2.40E+01 3.08E-16 0.000 0.9519 0.9000 0.9373 -0.19 3 3 4.3E-08
50 : 2.39E+01 2.94E-16 0.000 0.9559 0.9000 0.9348 -0.14 3 3 4.2E-08
51 : 2.38E+01 2.81E-16 0.000 0.9566 0.9000 0.9363 -0.11 3 3 4.1E-08
52 : 2.37E+01 2.67E-16 0.000 0.9469 0.9154 0.9000 -0.04 3 3 4.0E-08
53 : 2.35E+01 2.50E-16 0.000 0.9377 0.9000 0.9554 -0.17 3 3 3.9E-08
54 : 2.34E+01 2.35E-16 0.000 0.9388 0.9000 0.9416 -0.19 3 3 3.8E-08
55 : 2.33E+01 2.21E-16 0.000 0.9437 0.9000 0.9370 -0.15 3 3 3.7E-08
56 : 2.31E+01 2.08E-16 0.000 0.9381 0.9000 0.9412 -0.20 3 3 3.6E-08
57 : 2.30E+01 1.96E-16 0.000 0.9430 0.9000 0.9349 -0.15 3 3 3.5E-08
58 : 2.29E+01 1.85E-16 0.000 0.9468 0.9000 0.9336 -0.07 3 3 3.4E-08
59 : 2.27E+01 1.75E-16 0.000 0.9460 0.9000 0.9345 -0.09 3 3 3.3E-08
60 : 2.26E+01 1.65E-16 0.000 0.9424 0.9000 0.9353 -0.11 3 3 3.2E-08
61 : 2.25E+01 1.55E-16 0.000 0.9347 0.9000 0.9392 -0.16 3 3 3.2E-08
62 : 2.23E+01 1.45E-16 0.000 0.9394 0.9000 0.9319 -0.12 3 3 3.1E-08
63 : 2.22E+01 1.37E-16 0.000 0.9414 0.9000 0.9324 -0.05 3 3 3.0E-08
64 : 2.21E+01 1.29E-16 0.000 0.9405 0.9000 0.9319 -0.06 3 3 2.9E-08
65 : 2.19E+01 1.20E-16 0.000 0.9372 0.9000 0.9337 -0.06 3 3 2.8E-08
66 : 2.18E+01 1.12E-16 0.000 0.9312 0.9000 0.9351 -0.11 3 3 2.7E-08
67 : 2.16E+01 1.04E-16 0.000 0.9257 0.9000 0.9350 -0.13 3 3 2.7E-08
68 : 2.14E+01 9.62E-17 0.000 0.9269 0.9000 0.9326 -0.11 3 3 2.6E-08
69 : 2.13E+01 9.10E-17 0.000 0.9454 0.9000 0.6121 -0.04 3 3 2.5E-08
70 : 2.12E+01 8.57E-17 0.000 0.9419 0.9000 0.5610 -0.04 3 3 2.4E-08
71 : 2.11E+01 8.03E-17 0.000 0.9375 0.9000 0.9000 -0.03 3 2 2.4E-08
72 : 2.10E+01 7.47E-17 0.000 0.9298 0.9000 0.9000 -0.05 2 3 2.3E-08
73 : 2.08E+01 6.88E-17 0.000 0.9209 0.9000 0.9000 -0.05 3 3 2.2E-08
74 : 2.07E+01 6.30E-17 0.000 0.9157 0.9000 0.9000 -0.05 2 2 2.1E-08
75 : 2.04E+01 5.59E-17 0.000 0.8868 0.9000 0.9000 -0.01 2 2 2.0E-08
76 : 2.03E+01 5.11E-17 0.000 0.9154 0.9000 0.9000 -0.01 2 2 1.9E-08
77 : 2.01E+01 4.59E-17 0.000 0.8971 0.9000 0.9000 -0.00 2 2 1.9E-08
78 : 1.99E+01 4.11E-17 0.000 0.8951 0.9000 0.9000 -0.03 2 2 1.8E-08
79 : 1.96E+01 3.63E-17 0.000 0.8842 0.9000 0.9000 -0.04 2 2 1.7E-08
80 : 1.94E+01 3.18E-17 0.000 0.8769 0.9000 0.9000 -0.02 2 2 1.6E-08
81 : 1.89E+01 2.61E-17 0.000 0.8210 0.9000 0.9000 0.00 2 2 1.4E-08

iter seconds digits cx by
81 83.8 Inf 1.8941010498e+01 1.8946374172e+01
|Ax-b| = 2.4e-07, [Ay-c]_+ = 2.7E+00, |x|= 2.9e-02, |y|= 4.2e+07

## Detailed timing (sec) Pre IPM Post 1.244E+01 7.062E+01 2.410E-01 Max-norms: ||b||=1.562857e-04, ||c|| = 7.099189e+08, Cholesky |add|=0, |skip| = 0, ||L.L|| = 793.295.

Status: Solved
Optimal value (cvx_optval): +48.2208

cvx_version

## Installation info: Path: G:\matlab\1\cvx MATLAB version: 8.6 (R2015b) OS: Windows 7 amd64 version 6.1 Java version: 1.7.0_60 Verfying CVX directory contents: No missing files. Preferences: Path: C:\Users\Administrator.AB-201810261518\AppData\Roaming\MathWorks\MATLAB\cvx_prefs.mat License host: Username: Administrator Host ID: d053498da2d3 (eth4) Host ID: f0761c7c2f6c (eth5) Installed license: No license installed.

(zhangQK) #10

Could you tell me how to show output by document?
Because the length of variables is too long.

(Mark L. Stone) #11

There is no evidence of any problem in your CVX installation. You are using CVX 2.1, which, unlike CVX 3,.0beta, is not know to have many bugs

Just copy and paste into a post, MATLAB calculations and results which demonstrate constraint violations.You don’t have to show us 19710 elements in violation. For instance, show `min(PEGU`).

Also, can you tell us what the largest and smallest magnitude non zero numbers are in your input data? maybe one of the Mosek guys can interpret the SeDuMi output for what that indicates about the numerics.

(zhangQK) #12

min(PEGU)=-2.1114, max(PEGU)=80.7343,
min(PB)=-32.2938, max(PB)=79.6354,
min(E)=9.76110^4,max(E)=1.013110^5.

input data:
min(Pr)=-30, max(Pr)=161.2299,

Are they enough?
I want to know the possible reasons for this phenomenon.Or what can I try to do to solve this problem?

(Erling D.Andersen) #13

This

says that the norm of the dual solution is bit large and there are big violations in dual solution. Since the problem is dualized that means your primal solution is inaccurate.

I would try Mosek instead of SeDuMi.

(zhangQK) #14

Hi,Erling. I reran the program by mosek,but it appeared the error called ‘cvx_status is Inaccurate/Infeasible’. So I think it is better to run the program by sedumi.
For the above problem by sedumi, could you tell me more information about the problem so that I can modify the problem.
Thank you.

(Erling D.Andersen) #15

Since I am not the author of SeDuMi I cannot help you with it.

Most likely you have a nasty problem since two optimizers did not produce a useful result.
Have fun.