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. The function power(expr, p).# Problem specs. The power operator expr**p is equivalent to The transpose of any expression can be obtained using the syntaxĮxpr.T. O dimensional : () 1 dimensional : ( 1 ,) Transpose ¶ Indexing drops dimensions while slicing preserves dimensions. While expr selects both rows and columns. If expr is a matrix, then expr selects rows, More generally, expr selects every kthĮlement of expr, starting at i and ending at j-1. ![]() Indexing in CVXPY follows exactly the same semantics as NumPy ndarrays.įor example, if expr has shape (5,) then expr gives the second entry. * should be matrix-scalar and vector-scalar multiplicationĮlementwise multiplication can be applied with the multiply function. Starting with Python 3.5, users can writeĮxpr1 expr2 for matrix multiplication and dot products.Īs of CVXPY version 1.1, we are adopting a new should be used for matrix-matrix and matrix-vector multiplication, Historically, CVXPY used expr1 * expr2 to denote matrix multiplication. ![]() The expression expr1*expr2 is affine inĬVXPY when one of the expressions is constant, and expr1/expr2 is affine The infix operators +, -, *, /, are treated as functions. The DCP rules to mark expressions with a sign and curvature. value ( numeric type) A value to assign to the variable. CVXPY uses the function information in this section and Parameters: shape ( tuple or int) The variable dimensions (0D by default). This section of the tutorial describes the atomic functions that can be applied
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |