test4.m

来自「HERE IS A GOOD PSO TOOL BOX」· M 代码 · 共 43 行

M
43
字号
%----------------------------------------------------------------------%%       TEST 4%%----------------------------------------------------------------------%%    This script is for testing GP solver.%    It generates various random problem data and solves this problem.%    mkgp is a Matlab function that generates random problem data%    which is originally written by Lieven Vandenberghe and%    modified by Kwangmoo Koh.close all; clear all;randn('state',0);rand('state',0);% the size of problem data.%% n : # of variable% m : # of inequality constraints% w : # of terms in each inequality constraint% p : # of equality constraints%        m*w >= n >= p in general.% s : # of average variables per monomial%n = 100; m = 1000; w = 50; p = 50; nnz = 500000;sparsity = nnz/(n*m*w)disp(sprintf('n = %d, m = %d, w = %d, p = %d, nnz = %d',n,m,w,p,nnz))szs = w*ones(m+1,1);% generate random problem datadisp('setting up the problem data...');[A,b,G,h,x0,nu] = mkgp(n, szs, p, 0, sparsity);disp('solving the problem...');% solve the problem using gpcvxtic[x1,status1,lambda1,nu1,mu1] = gpcvx(A,b,szs,G,h);toc

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?