+++++++++++++++++++++++++++++++++++++++++++++++ | Searching for installed solvers | +++++++++++++++++++++++++++++++++++++++++++++++ | Solver| Version/module| Status| +++++++++++++++++++++++++++++++++++++++++++++++ | BARON| | not found| | BINTPROG| | not found| | BISECTION| | found| | BMIBNB| | found| | BNB| | found| | BONMIN| | not found| | BPMPD| | not found| | CBC| | not found| | CDCS| | not found| | CDD| CDDMEX| not found| | CLP| CLPMEX-LP| not found| | CLP| CLPMEX-QP| not found| | CLP| OPTI| not found| | CONEPROG| | found| | CPLEX| IBM 12.10.0| not found| | CPLEX| IBM 12.10.0| not found| | CPLEX| IBM 12.9.0| not found| | CPLEX| IBM 12.9.0| not found| | CPLEX| IBM 12.8.0| not found| | CPLEX| IBM 12.8.0| not found| | CPLEX| IBM 12.7.1| not found| | CPLEX| IBM 12.7.1| not found| | CPLEX| IBM 12.7.0| not found| | CPLEX| IBM 12.7.0| not found| | CPLEX| IBM 12.6.3| not found| | CPLEX| IBM 12.6.3| not found| | CPLEX| IBM 12.6.2| not found| | CPLEX| IBM 12.6.2| not found| | CPLEX| IBM 12.6.1| not found| | CPLEX| IBM 12.6.1| not found| | CPLEX| IBM 12.6.0| not found| | CPLEX| IBM 12.6.0| not found| | CPLEX| IBM 12.5.1| not found|
此时,你可以 Press any key to continue test 按下任意键以继续测试,也可以 Ctrl+C 以取消继续的测试。
| CLP| CLPMEX-QP| not found| | CLP| OPTI| not found| | CONEPROG| | found| | CPLEX| IBM 12.10.0| found| <------!!! | CPLEX| IBM 12.10.0| found| <------!!! | CPLEX| IBM 12.9.0| not found| | CPLEX| IBM 12.9.0| not found| | CPLEX| IBM 12.8.0| not found| | CPLEX| IBM 12.8.0| not found| | CPLEX| IBM 12.7.1| not found| | CPLEX| IBM 12.7.1| not found| | CPLEX| IBM 12.7.0| not found| | CPLEX| IBM 12.7.0| not found|
clear; W = 3000; H = 1500; sizes = [373, 201; 406, 229]; % W = 15; % H = 20; % sizes = [3, 2; 4, 5]; numTypes = size(sizes, 1);
x=binvar(W,H,numTypes); % cover=binvar(W,H);
C=[]; for t = 1:numTypes w = sizes(t, 1); h = sizes(t, 2); fori = 1:W fprintf("构建第%d行\n",i); forj = 1:H ifi+w-1>W || j+h-1>H C = [C, x(i,j,t)==0]; else % 如果在 (i, j) 放置了形状 t % 则 (i:i+w-1, j:j+h-1) 内的所有点都不能再放置其他形状 for ii=i:i+w-1 for jj=j:j+h-1 for tt=1:numTypes ifi==ii && j==jj && t==tt continue end C=[C,x(i,j,t)~=x(ii,jj,tt)]; end end end end end end end
disp("约束条件构建完毕"); ops=sdpsettings('verbose',0,'solver','cplex'); area=sizes(:,1).*sizes(:,2); z=(sum(x(:,:,1))*area(1)+sum(x(:,:,2))*area(2)); reuslt=optimize(C,z); if result.problem == 0 % value(x) value(z) else disp('求解过程中出错'); end