

Nonneg ( bool) – Is the variable constrained to be nonnegative? Value ( numeric type) – A value to assign to the variable. Shape ( tuple or int) – The variable dimensions (0D by default). Only one attribute can be active (set to True). Leaf ( shape = None, value = None, nonneg = False, nonpos = False, complex = False, imag = False, symmetric = False, diag = False, PSD = False, NSD = False, hermitian = False, boolean = False, integer = False, sparsity = None, pos = False, neg = False ) ¶Ĭreates a Leaf object (e.g., Variable or Parameter).
#SETTING AN ARRAY ELEMENT WITH A SEQUENCE CVXPY FULL#
The full constructor for Leaf (the parent class Similarly, Parameter(nonpos=True) is a scalar parameter constrained to be nonpositive. Variables and parameters can be created with attributes specifying additional properties.įor example, Variable(nonneg=True) is a scalar variable constrained to be nonnegative. The fact that the dual variable is non-zero also tells us that if we tighten x - y >= 1, (i.e., increase the right-hand side), the optimal value of the problem will increase. By complementarity this implies that x - y is 1, which we can see is true. theta_1 = theta_tar + halfbeam theta_2 = theta_tar - halfbeam plt. format ( min_sidelobe ), fontsize = 16 ) #Lobe center and boundaries angles.

SCS ) #if prob.status != cp.OPTIMAL: # raise Exception('CVXPY Error') print ( "final objective value: dB'. norm ( As_ri_row * w_ri ) <= 10 ** ( min_sidelobe / 20 ) ) # Form and solve problem. vstack (( As_RI_top, As_RI_bot )) constraints. block () constraints = # Same constraint as a above, on new As (hense different # actual number of constraints). Variable ( shape = ( 2 * n )) constraints = # Must add complex valued constraint # abs(As*w = ( theta_tar + halfbeam ) )))) As = A ,:] # As as # See earlier calculations for real/imaginary representation As_R = As. array () # Create cvxpy variables and constraints w_ri = cp. block () # 1-vector as since no imaginary part realones_ri = np. # Vectors are stored and matrices as : # Atar as Atar_R = Atar. # As of this writing (4) cvxpy does not do complex valued math, # so the real and complex values must be stored separately as reals # and operated on as follows: # Let any vector or matrix be represented as a+bj, or A+Bj. Theta = ( theta_tar + halfbeam_cur ) )))) As = A ,:] # Formulate and solve the feasibility antenna array problem. ceil ( ( halfbeam_top + halfbeam_bot ) / 2.0 ) # Create optimization matrices for the stopband, # i.e. while halfbeam_top - halfbeam_bot > 1 : # Width in degrees of the current half-beam. halfbeam_bot = 1 halfbeam_top = max_half_beam print ( 'We are only considering integer values of the half beam-width' ) print ( '(since we are sampling the angle with 1 degree resolution).' ) print ( '' ) # Iterate bisection until 1 angular degree of uncertainty. abs ( theta - theta_tar )) Atar = A Solve using bisection algorithm ¶ pi * 1 j / lambda_wl * A ) # Target constraint matrix. # Build matrix A that relates w and y(theta), ie, y = A*w. zeros (( n, 2 )) for x in range ( m ): for y in range ( m ): loc = loc = loc * d else : raise Exception ( 'Undefined array geometry' ) # Construct optimization data. # elif ARRAY_GEOMETRY = '2D_UNIFORM_LATTICE' : m = 6 n = m ** 2 d = 0.45 * lambda_wl loc = np.

zeros (( n, 1 )) )) # 2D_UNIFORM_LATTICE: # Uniform 2D array with m-by-m element with d spacing. # elif ARRAY_GEOMETRY = '1D_UNIFORM_LINE' : n = 30 d = 0.45 * lambda_wl loc = np. random (( n, 2 )) # 1D_UNIFORM_LINE: # Uniform 1D array with n elements with inter-element spacing d.

seed ( 1 ) # Uniformly distributed on -by- square. # if ARRAY_GEOMETRY = '2D_RANDOM' : # Set random seed for repeatable experiments. # lambda_wl = 1 # wavelength theta_tar = 60 # target direction min_sidelobe = - 20 # maximum sidelobe level in dB max_half_beam = 50 # starting half beamwidth (must be feasible) # 2D_RANDOM: # n randomly located elements in 2D.
