clear;close;clc;A=[1 2 3;4 5 6]A =1 2 34 5 6A=[1:3;4:6]A =1 2 34 5 6A=zeros(2,3)A =0 0 00 0 0A=eye(3,3)A =1 0 00 1 00 0 1C=hadamard(4)C =1 1 1 11 -1 1 -11 1 -1 -11 -1 -1 1help toeplitzTOEPLITZ Toeplitz matrix.TOEPLITZ(C,R) is a non-symmetric Toeplitz matrix having C as itsfirst column and R as its first row.TOEPLITZ(R) is a symmetric Toeplitz matrix for real R.For a complex vector R with a real first element, T = toeplitz(r) returns the Hermitian Toeplitz matrix formed from R. When thefirst element of R is not real, the resulting matrix is Hermitian off the main diagonal, i.e., T_{i,j} = conj(T_{j,i}) for i ~= j.Class support for inputs C,R:float: double, singleSee also HANKEL.Overloaded methods:sdpvar/toeplitzncvar/toeplitzA=[1 2 3];B=4:6;C1=cat(1,A,B)C1 =1 2 34 5 6C2=cat(2,A,B)C2 =1 2 3 4 5 6 C3=cat(3,A,B)C3(:,:,1) =1 2 3C3(:,:,2) =4 5 6horzcat(A,B)ans =1 2 3 4 5 6 vertcat(A,B)ans =1 2 34 5 6A=1:9;A=reshape(A,3,3)'A =1 2 34 5 67 8 9A(2,3)ans =6A(8)ans =6B=A(1:2,:)B =1 2 34 5 6A(:,[1 2])=[]A =369C=reshape(B,1,6)C =1 42 53 6 A*C(1:3)ans =3 12 66 24 129 36 18C'ans =142536x=sdpvar(1,3)%f=[2 -2 3]*x'f=2*x(1)-2*x(2)+3*x(3)F=set(x(1)<=0)+set(x(2)>=0)%F=F+set([-1 1 1]*x'<=4)+set([-1 1 1]*x'>=4)+set([-2 1 -1]*x'<=6)F=F+set([-1 1 1]*x'==4)+set([-2 1 -1]*x'<=6)solvesdp(F,f)double(f)double(x)Linear matrix variable 1x3 (full, real, 3 variables)Linear scalar (real, 3 variables)+++++++++++++++++++++++++++++++++++++++++++++++++++++++| ID| Constraint| Type|+++++++++++++++++++++++++++++++++++++++++++++++++++++++| #1| Numeric value| Element-wise inequality 1x1|| #2| Numeric value| Element-wise inequality 1x1|++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| ID| Constraint| Type|+++++++++++++++++++++++++++++++++++++++++++++++++++++++| #1| Numeric value| Element-wise inequality 1x1|| #2| Numeric value| Element-wise inequality 1x1|| #3| Numeric value| Equality constraint 1x1|| #4| Numeric value| Element-wise inequality 1x1|+++++++++++++++++++++++++++++++++++++++++++++++++++++++Model name: '' - run #1Objective: Maximize(R0)SUBMITTEDModel size: 2 constraints, 3 variables, 6 non-zeros.Sets: 0 GUB, 0 SOS. Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.The primal and dual simplex pricing strategy set to 'Devex'.Found feasibility by dual simplex after 1 iter.Optimal solution 13 after 2 iter.Excellent numeric accuracy ||*|| = 0MEMO: lp_solve version 5.5.2.0 for 32 bit OS, with 64 bit REAL variables.In the total iteration count 2, 0 (0.0%) were bound flips.There were 2 refactorizations, 0 triggered by time and 0 by density.... on average 1.0 major pivots per refactorization.The largest [LUSOL v2.2.1.0] fact(B) had 5 NZ entries, 1.0xlargest basis.The constraint matrix inf-norm is 2, with a dynamic range of 2.Time to load data was 0.000 seconds, presolve used 0.000 seconds, ... 0.001 seconds in simplex solver, in total 0.001 seconds.ans =yalmiptime: 0.1020solvertime: 1.0000e-003info: 'No problems detected (LPSOLVE-MXLPSOLVE)'problem: 0dimacs: [NaN NaN NaN NaN NaN NaN]ans =-13.0000ans =0 5.0000 -1.0000m=intvar(1,1)n=intvar(1,1)g=intvar(1,1)Z=50*m+40*n+40*gF=set(m>=0)+set(m<=30)+set(n>=0)+set(n<=35)+set(g>=0)+set(g<=40)F=F+set(4*m+6*n+4*g<=440)+set(8*m+2*n+4*g<=480)+set(95*m+90*n+85*g<=800 0)solvesdp(F,-Z)Z=double(Z)m=double(m)n=double(n)g=double(g)Linear scalar (real, integer, 1 variable)Linear scalar (real, integer, 1 variable)Linear scalar (real, integer, 1 variable)Linear scalar (real, integer, 3 variables)+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| ID| Constraint| Type|+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| #1| Numeric value| Element-wise inequality (integer) 1x1|| #2| Numeric value| Element-wise inequality (integer) 1x1|| #3| Numeric value| Element-wise inequality (integer) 1x1|| #4| Numeric value| Element-wise inequality (integer) 1x1|| #5| Numeric value| Element-wise inequality (integer) 1x1|| #6| Numeric value| Element-wise inequality (integer) 1x1|++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| ID| Constraint| Type|+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| #1| Numeric value| Element-wise inequality (integer) 1x1|| #2| Numeric value| Element-wise inequality (integer) 1x1|| #3| Numeric value| Element-wise inequality (integer) 1x1|| #4| Numeric value| Element-wise inequality (integer) 1x1|| #5| Numeric value| Element-wise inequality (integer) 1x1|| #6| Numeric value| Element-wise inequality (integer) 1x1|| #7| Numeric value| Element-wise inequality (integer) 1x1|| #8| Numeric value| Element-wise inequality (integer) 1x1|| #9| Numeric value| Element-wise inequality (integer) 1x1|+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Model name: '' - run #1Objective: Maximize(R0)SUBMITTEDModel size: 3 constraints, 3 variables, 9 non-zeros.Sets: 0 GUB, 0 SOS. Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.The primal and dual simplex pricing strategy set to 'Devex'.Relaxed solution 3877.77777778 after 2 iter is B&B base. Feasible solution 3800 after 23 iter, 31 nodes (gap 2.0%)Improved solution 3810 after 28 iter, 36 nodes (gap 1.7%)Improved solution 3820 after 29 iter, 37 nodes (gap 1.5%)Improved solution 3830 after 30 iter, 38 nodes (gap 1.2%)Improved solution 3840 after 31 iter, 39 nodes (gap 1.0%)Improved solution 3850 after 32 iter, 40 nodes (gap 0.7%)Improved solution 3860 after 69 iter, 84 nodes (gap 0.4%)Optimal solution 3860 after 77 iter, 92 nodes (gap 0.4%).Excellent numeric accuracy ||*|| = 9.09495e-013MEMO: lp_solve version 5.5.2.0 for 32 bit OS, with 64 bit REAL variables.In the total iteration count 77, 0 (0.0%) were bound flips.There were 46 refactorizations, 0 triggered by time and 0 by density.... on average 1.7 major pivots per refactorization.The largest [LUSOL v2.2.1.0] fact(B) had 7 NZ entries, 1.0xlargest basis.The maximum B&B level was 22, 3.7x MIP order, 16 at the optimal solution.The constraint matrix inf-norm is 95, with a dynamic range of47.5.Time to load data was 0.000 seconds, presolve used 0.000 seconds, ... 0.002 seconds in simplex solver, in total 0.002 seconds.ans =yalmiptime: 0.0990solvertime: 0.0020info: 'No problems detected (LPSOLVE-MXLPSOLVE)'problem: 0dimacs: [NaN NaN NaN NaN NaN NaN]Z =3860m =30n =27g =32type 2.m%1x=sdpvar(1,3);%f=[2 -2 3]*x';f=2*x(1)-2*x(2)+3*x(3);F=set(x(1)<=0)+set(x(2)>=0);%F=F+set([-1 1 1]*x'<=4)+set([-1 1 1]*x'>=4)+set([-2 1 -1]*x'<=6); F=F+set([-1 1 1]*x'==4)+set([-2 1 -1]*x'<=6);solvesdp(F,f)double(f)double(x)%2x=intvar(1,2);f=[3 -1]*x';F=set(x>=0);F=F+set([3 -2]*x'<=3)+set([5 4]*x'>=10)+set(2*x(1)+x(2)<=5); solvesdp(F,-f)double(f)double(x)%3x=binvar(1,3);f=[3 -2 5]*x';F=set([1 2 -1]*x'<=2)+set([1 4 1]*x'<=4)+set([1 10]*x'<=3)+set(4*x(2)+x(3)<=6);solvesdp(F,-f)double(f)double(x)%4x=sdpvar(1,2);f=[1 1]*(x'.^2)+8;F=set(x>=0);F=F+set([1 -1]*(x'.^2)>=0)+set(-x(1)-x(2)^2+2>=0)+set(-x(1)-x(2)^2+2<=0);solvesdp(F,f)double(f)double(x)%微分方程%无显性求解,只能用数值解了。