├── LICENSE ├── Lauricella_FA.m ├── README.md ├── demo_main_FULL_Gamma.pdf ├── demo_main_FULL_LogNormal.pdf ├── demo_main_coChannel_interference_simulation.pdf.pdf ├── demo_main_energy_efficiency.pdf.pdf ├── main_FULL_Gamma.m ├── main_FULL_LogNormal.m ├── main_coChannel_interference_simulation.m ├── main_energy_efficiency.m └── nsumk.m /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Lauricella_FA.m: -------------------------------------------------------------------------------- 1 | % Multi-RIS-aided Wireless Systems: Statistical Characterization and Performance Analysis 2 | % Tri Nhu Do, Georges Kaddoum, Thanh Luan Nguyen, Daniel Benevides da Costa, and Zygmunt J. Haas 3 | % https://arxiv.org/abs/2104.01912 4 | % Version: 2021-04-05 5 | 6 | 7 | function out = Lauricella_FA(a, bvec, cvec, xvec) 8 | 9 | N = length(xvec); 10 | 11 | syms t x 12 | HypergeomProd = 1; 13 | 14 | for n = 1:N 15 | HypergeomProd = HypergeomProd... 16 | * hypergeom(bvec(n),cvec(n),xvec(n)*t); 17 | end 18 | 19 | intFunction = exp(-t)*t^(a-1)*HypergeomProd; 20 | 21 | % result(x) = vpaintegral(intFunction, t, 0, Inf)/gamma(x); 22 | result(x) = vpaintegral(intFunction, t, [0,Inf], 'RelTol', 1e-32, 'AbsTol', 0)/gamma(x); 23 | 24 | out = double(vpa(result(a))); 25 | end 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Multi-RIS-aided Wireless Systems: Statistical Characterization and Performance Analysis 2 | 3 | **Tri Nhu Do, Georges Kaddoum, Thanh Luan Nguyen, Daniel Benevides da Costa, Zygmunt J. Haas** 4 | 5 | ## Abstract 6 | In this paper, we study the statistical characterization and modeling of distributed multi-reconfigurable intelligent surface (RIS)-aided wireless systems. Specifically, we consider a practical system model where the RISs with different geometric sizes are distributively deployed, and wireless channels associated to different RISs are assumed to be independent but not identically distributed (i.n.i.d.). We propose two purpose-oriented multi-RIS-aided schemes, namely, the exhaustive RIS-aided (ERA) and opportunistic RIS-aided (ORA) schemes. In the ERA scheme, all RISs participate in assisting the communication of a pair of transceivers, whereas in the ORA scheme, only the most appropriate RIS participates and the remaining RISs are utilized for other purposes. A mathematical framework, which relies on the method of moments, is proposed to statistically characterize the end-to-end (e2e) channels of these schemes. It is shown that either a Gamma distribution or a LogNormal distribution can be used to approximate the distribution of the magnitude of the e2e channel coefficients in both schemes. With these findings, we evaluate the performance of the two schemes in terms of outage probability (OP) and ergodic capacity (EC), where tight approximate closed-form expressions for the OP and EC are derived. Representative results show that the ERA scheme outperforms the ORA scheme in terms of OP and EC. Nevertheless, the ORA scheme gives a better energy efficiency (EE) in a specific range of the target spectral efficiency (SE). In addition, under i.n.i.d. fading channels, the reflecting element setting and location setting of RISs have a significant impact on the overall system performance of both the ERA or ORA schemes. A centralized large-RIS-aided scheme might achieve higher EC than the distributed ERA scheme when the large-RIS is located near a transmitter or a receiver, and vice-versa. 7 | 8 | ## Paper 9 | - [Preprint on arXiv](https://arxiv.org/abs/2104.01912) 10 | - [IEEExplore](https://ieeexplore.ieee.org/document/9558795) 11 | -------------------------------------------------------------------------------- /demo_main_FULL_Gamma.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trinhudo/Multi-RIS/2a6abf7d544e2a951f63deb788a651a1db56685b/demo_main_FULL_Gamma.pdf -------------------------------------------------------------------------------- /demo_main_FULL_LogNormal.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trinhudo/Multi-RIS/2a6abf7d544e2a951f63deb788a651a1db56685b/demo_main_FULL_LogNormal.pdf -------------------------------------------------------------------------------- /demo_main_coChannel_interference_simulation.pdf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trinhudo/Multi-RIS/2a6abf7d544e2a951f63deb788a651a1db56685b/demo_main_coChannel_interference_simulation.pdf.pdf -------------------------------------------------------------------------------- /demo_main_energy_efficiency.pdf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trinhudo/Multi-RIS/2a6abf7d544e2a951f63deb788a651a1db56685b/demo_main_energy_efficiency.pdf.pdf -------------------------------------------------------------------------------- /main_FULL_Gamma.m: -------------------------------------------------------------------------------- 1 | %% PAPER 2 | 3 | % Title: Multi-RIS-aided Wireless Systems: Statistical Characterization and Performance Analysis 4 | % Authors : Tri Nhu Do, Georges Kaddoum, Thanh Luan Nguyen, Daniel Benevides da Costa, Zygmunt J. Haas 5 | % Online: https://github.com/trinhudo/Multi-RIS 6 | % Version: 12-Sep-2021 7 | 8 | % Multiple RISs with detailed phase-shift configuration 9 | % --ERA scheme: all RISs participate 10 | % --ORA scheme: only the best RIS participates 11 | % --Analysis is based on Gamma distribution 12 | 13 | tic 14 | % rng('default'); 15 | 16 | %% SETTING 17 | 18 | clear all 19 | close all 20 | 21 | sim_times = 1e5; % Number of simulation trails 22 | 23 | R_th = 1; % Predefined target spectral efficiency [b/s/Hz] 24 | 25 | SNR_th = 2^R_th-1; % Predefined SNR threshold 26 | 27 | N_RIS = 5; % Number of distributed RISs 28 | 29 | L_single = 25; % Number of elements at each RIS 30 | 31 | L = L_single*ones(1,N_RIS); % all RISs 32 | 33 | kappa_nl = 1; % Amplitude reflection coefficient 34 | 35 | % Network area 36 | x_area_min = 0; 37 | x_area_max = 100; % in meters 38 | y_area_min = 0; 39 | y_area_max = 10; 40 | 41 | % Source location 42 | x_source = x_area_min; 43 | y_source = y_area_min; 44 | 45 | % Destination location 46 | x_des = x_area_max; 47 | y_des = y_area_min; 48 | 49 | % Random location setting 50 | % x_RIS = x_area_min + (x_area_max-x_area_min)*rand(N_RIS, 1); % [num_RIS x 1] vector 51 | % y_RIS = y_area_min + (y_area_max-y_area_min)*rand(N_RIS, 1); 52 | 53 | %Location setting D1 54 | x_RIS = [7; 13; 41; 75; 93]; 55 | y_RIS = [2; 6; 8; 4; 3]; 56 | 57 | % Compute location of nodes 58 | pos_source = [x_source, y_source]; 59 | 60 | pos_des = [x_des, y_des]; 61 | pos_RIS = [x_RIS, y_RIS]; % [num_RIS x 2] matrix 62 | 63 | % Compute distances 64 | d_SR = sqrt(sum((pos_source - pos_RIS).^2 , 2)); % [num_RIS x 1] vector 65 | d_RD = sqrt(sum((pos_RIS - pos_des).^2 , 2)); 66 | d_SD = sqrt(sum((pos_source - pos_des).^2 , 2)); 67 | 68 | %% NETWORK TOPOLOGY 69 | 70 | figure; 71 | 72 | scatter(x_source, y_source, 100, 'b^', 'filled'); hold on 73 | scatter(x_des, y_des, 100, 'go', 'filled'); hold on 74 | scatter(x_RIS, y_RIS, 100, 'rs', 'filled'); hold on 75 | 76 | for kk = 1:N_RIS 77 | text(x_RIS(kk)+3, y_RIS(kk)+0.1, num2str(kk)); 78 | hold on 79 | end 80 | 81 | xlabel('$d_{\rm SD}$ (m)', 'Interpreter', 'Latex') 82 | ylabel('$H$ (m)', 'Interpreter', 'Latex') 83 | axis([x_area_min x_area_max y_area_min y_area_max]) 84 | legend('$\rm S$', '$\rm D$', '$\mathrm{R}_i$',... 85 | 'Interpreter', 'Latex',... 86 | 'Location', 'best') 87 | 88 | set(gca, 'LooseInset', get(gca, 'TightInset')) % remove plot padding 89 | set(gca,'fontsize',13); 90 | hold off 91 | 92 | % Path-loss model 93 | % --------------- 94 | % Following: https://github.com/emilbjornson/IRS-relaying 95 | 96 | % Carrier frequency (in GHz) 97 | fc = 3; % GHz 98 | 99 | % 3GPP Urban Micro in 3GPP TS 36.814 100 | % NLoS path-loss component based on distance, x is in meter 101 | pathloss_NLOS = @(x) db2pow(-22.7 - 26*log10(fc) - 36.7*log10(x)); 102 | 103 | antenna_gain_S = db2pow(5); % Source antenna gain, dBi 104 | antenna_gain_RIS = db2pow(5); % Gain of each element of a RIS, dBi 105 | antenna_gain_D = db2pow(0); % Destination antenna gain, dBi 106 | 107 | % Noise power and Transmit power P_S 108 | % ---------------------------------- 109 | 110 | % Bandwidth 111 | BW = 10e6; % 10 MHz 112 | 113 | % Noise figure (in dB) 114 | noiseFiguredB = 10; 115 | 116 | % Compute the noise power in dBm 117 | sigma2dBm = -174 + 10*log10(BW) + noiseFiguredB; % -94 dBm 118 | sigma2 = db2pow(sigma2dBm); 119 | 120 | P_S_dB = -5:25; % Transmit power of the source, dBm, e.g., 200mW = 23dBm 121 | 122 | SNRdB = P_S_dB - sigma2dBm; % Average transmit SNR, dB = dBm - dBm, bar{rho} = P_S / sigma2 123 | 124 | %% SIMULATION | ERA SCHEME 125 | 126 | % Nakagami scale parameter 127 | m_0 = 2.5 + rand; % S->D, scale parameter, heuristic setting 128 | 129 | m_h = 2.5 + rand(N_RIS, 1); % S->R 130 | 131 | m_g = 2.5 + rand(N_RIS, 1); % R->D 132 | 133 | % Nakagami spread parameter 134 | 135 | Omega_0 = 1; % Normalized spread parameter of S->D link 136 | Omega_h = 1; % Normalized spread parameter of S->RIS link 137 | Omega_g = 1; % Normalized spread parameter of RIS->D link 138 | 139 | % Path-loss 140 | 141 | path_loss_0 = pathloss_NLOS(d_SD)*antenna_gain_S; % S->D link 142 | 143 | path_loss_h = pathloss_NLOS(d_SR) * ... 144 | antenna_gain_S*antenna_gain_RIS*L_single; % Source -> RIS 145 | 146 | path_loss_g = pathloss_NLOS(d_RD) * ... 147 | antenna_gain_RIS*L_single*antenna_gain_D; % RIS -> Des 148 | 149 | % Phase of channels 150 | 151 | phase_h_SD = 2*pi*rand(1, sim_times); % domain [0,2pi) 152 | phase_h_SR = 2*pi*rand(N_RIS, L_single, sim_times); % domain [0,2pi) 153 | phase_g_RD = 2*pi*rand(N_RIS, L_single, sim_times); % domain [0,2pi) 154 | 155 | phase_h_SR_eachRIS = zeros(L_single, sim_times); 156 | phase_g_RD_eachRIS = zeros(L_single, sim_times); 157 | 158 | % Channel modeling 159 | 160 | h_SD = sqrt(path_loss_0) * ... % need sqrt because path-loss is outside of random() 161 | random('Naka', m_0, Omega_0, [1, sim_times]) .* ... 162 | exp(1i*phase_h_SD); 163 | 164 | h_SR = zeros(N_RIS,L_single,sim_times); % S to RIS channel 165 | g_RD = zeros(N_RIS,L_single,sim_times); % RIS to D channel 166 | 167 | for nn = 1:N_RIS 168 | phase_h_SR_eachRIS = squeeze(phase_h_SR(nn,:,:)); % random() just uses 2D 169 | phase_g_RD_eachRIS = squeeze(phase_g_RD(nn,:,:)); % random() just uses 2D 170 | 171 | for kk=1:L(nn) 172 | h_SR(nn,kk,:) = sqrt(path_loss_h(nn)) .* ... % need sqrt because path-loss is outside of random() 173 | random('Naka', m_h(nn), Omega_h, [1, sim_times]) .* ... 174 | exp(1i*phase_h_SR_eachRIS(kk,:)); 175 | 176 | g_RD(nn,kk,:) = sqrt(path_loss_g(nn)) .* ... % need sqrt because path-loss is outside of random() 177 | random('Naka', m_g(nn), Omega_g, [1, sim_times]) .* ... 178 | exp(1i*phase_g_RD_eachRIS(kk,:)); 179 | end 180 | end 181 | 182 | % Phase-shift Configuration for ERA scheme 183 | %----------------------------------------- 184 | 185 | h_ERA_cascade = zeros(N_RIS, sim_times); % matrix of cascade channel S-via-RIS-to-D 186 | 187 | for ss = 1:sim_times % loop over simulation trials 188 | phase_shift_config_ideal = zeros(L_single,1); 189 | phase_shift_config_ideal_normalized = zeros(L_single,1); 190 | phase_shift_complex_vector = zeros(L_single,1); 191 | 192 | for nn=1:N_RIS % loop over each RIS 193 | for ll = 1:L_single % loop over each elements of one RIS 194 | % Unknown domain phase-shift 195 | phase_shift_config_ideal(ll) = ... 196 | phase_h_SD(ss) - phase_h_SR(nn,ll,ss) - phase_g_RD(nn,ll,ss); 197 | % Convert to domain of [0, 2pi) 198 | phase_shift_config_ideal_normalized(ll) = wrapTo2Pi(phase_shift_config_ideal(ll)); 199 | phase_shift_complex_vector(ll) = exp(1i*phase_shift_config_ideal_normalized(ll)); 200 | end 201 | 202 | phase_shift_matrix = kappa_nl .* diag(phase_shift_complex_vector); 203 | 204 | % Cascade channel (complex, not magnitude) 205 | h_ERA_cascade(nn,ss) = h_SR(nn,:,ss) * phase_shift_matrix * g_RD(nn,:,ss).'; % returns a number 206 | end 207 | end 208 | 209 | h_ERA_e2e_magnitude = abs(h_SD + sum(h_ERA_cascade,1)); % direct + cascade channels 210 | 211 | Z_ERA = h_ERA_e2e_magnitude; % RV Z in the analysis 212 | 213 | Z2_ERA = Z_ERA.^2; % RV Z^2 214 | 215 | %% SIMULATION | ORA SCHEME (BEST RIS SELECTION) 216 | 217 | % Simple simulation 218 | %------------------ 219 | 220 | % V_M_ORA = max(h_e2e_RIS_path, [], 1); %V_M for the best RIS 221 | % R_ORA = abs(h_SD + V_M_ORA); %Magnitude of the e2e channel 222 | % R2_ORA = R_ORA.^2; %Squared magnitude of the e2e channel 223 | 224 | % Detailed simulation 225 | %-------------------- 226 | 227 | h_ORA_cascade = zeros(1, sim_times); 228 | 229 | [~,idx] = max(h_ERA_cascade,[],1); 230 | 231 | for ss = 1:sim_times 232 | phase_shift_config_ideal = zeros(L_single,1); 233 | phase_shift_config_ideal_normalized = zeros(L_single,1); 234 | phase_shift_complex_vector = zeros(L_single,1); 235 | for ll = 1:L_single % loop over each elements of one RIS 236 | % Unknown domain phase-shift 237 | phase_shift_config_ideal(ll) = phase_h_SD(ss) - phase_h_SR(idx(ss),ll,ss) - phase_g_RD(idx(ss),ll,ss); 238 | phase_shift_config_ideal_normalized(ll) = wrapTo2Pi(phase_shift_config_ideal(ll)); 239 | phase_shift_complex_vector(ll) = exp(1i*phase_shift_config_ideal_normalized(ll)); 240 | end 241 | 242 | phase_shift_matrix = kappa_nl .* diag(phase_shift_complex_vector); 243 | 244 | % e2e channel coefficient (complex number, not magnitude) 245 | h_ERA_cascade(idx(ss),ss) = h_SR(idx(ss),:,ss) * phase_shift_matrix * g_RD(idx(ss),:,ss).'; 246 | 247 | h_ORA_cascade(ss) = h_ERA_cascade(idx(ss),ss); 248 | end 249 | 250 | h_ORA_e2e_magnitude = abs(h_SD + h_ORA_cascade); 251 | 252 | R_ORA = h_ORA_e2e_magnitude; % RV R in the analysis 253 | 254 | R2_ORA = h_ORA_e2e_magnitude.^2; % RV R^2 255 | 256 | %% ANALYSIS | ERA SCHEME | GAMMA DISTRIBUTION 257 | 258 | Omg_0 = Omega_0*path_loss_0; 259 | Omg_h = Omega_h*path_loss_h; 260 | Omg_g = Omega_g*path_loss_g; 261 | 262 | lambda = sqrt(m_h./Omg_h .* m_g./Omg_g) ./ kappa_nl; % lambda_nl 263 | 264 | % Working on h0 265 | %-------------- 266 | 267 | %The k-th moment of h0 268 | E_h0_k = @(k) gamma(m_0+k/2)/gamma(m_0)*(m_0/Omg_0)^(-k/2); 269 | 270 | %CDF of h0 271 | F_h0 = @(x) gammainc(m_0*double(x).^2/Omg_0, m_0, 'lower'); 272 | 273 | %PDF of h0 274 | f_h0 = @(x) 2*m_0^m_0/gamma(m_0)/Omg_0^m_0*double(x).^(2*m_0-1).*exp(-m_0/Omg_0.*double(x).^2); 275 | 276 | % Working on U_nl 277 | %---------------- 278 | 279 | %The k-moment of U_nl 280 | E_U_nl_k = @(k,n) lambda(n)^(-k)*gamma(m_h(n)+0.5*k)... 281 | * gamma(m_g(n)+0.5*k) / gamma(m_h(n)) / gamma(m_g(n)); 282 | 283 | %Parameter of the approximate Gamma distribution of U_nl 284 | alpha_U= @(n) E_U_nl_k(1,n)^2/(E_U_nl_k(2,n)-E_U_nl_k(1,n)^2); 285 | beta_U = @(n) E_U_nl_k(1,n)/(E_U_nl_k(2,n)-E_U_nl_k(1,n)^2); 286 | 287 | %PDF of U_nl 288 | f_U_nl = @(x,n) beta_U(n)^alpha_U(n)/gamma(alpha_U(n))... 289 | * x.^(alpha_U(n)-1) .* exp( -beta_U(n)*x ); 290 | 291 | % Working on V_n 292 | %--------------- 293 | 294 | %The k-moment of V_n 295 | E_V_n_k = @(k,n) gamma(L(n) * alpha_U(n)+k) ... 296 | / gamma(L(n) * alpha_U(n)) * beta_U(n)^(-k); 297 | 298 | %PDF of V_n 299 | f_V_n = @(v,n) vpa(beta_U(n)^(sym(L(n)*alpha_U(n)))/gamma(sym(L(n)*alpha_U(n))))... 300 | * v.^(L(n)*alpha_U(n)-1) .* exp(-beta_U(n)*v); 301 | 302 | %CDF of V_n 303 | F_V_n = @(v,n) gammainc(beta_U(n)*double(v),L(n)*alpha_U(n),'lower'); 304 | 305 | % Working on T 306 | %------------- 307 | 308 | % The 1st moment of T 309 | E_T_1 = 0; 310 | 311 | for nn = 1:N_RIS 312 | for kk = 1:L(nn) 313 | E_T_1 = E_T_1 + E_U_nl_k(1,nn); 314 | end 315 | end 316 | 317 | %The 2nd moment of T 318 | 319 | E_T_2 = 0; 320 | 321 | for nn = 1:N_RIS 322 | tmpA = 0; 323 | for kk = 1:L(nn) 324 | tmpA = tmpA + E_U_nl_k(1,nn); 325 | end 326 | for ii = nn+1:N_RIS 327 | tmpB = 0; 328 | for kk = 1:L(ii) 329 | tmpB = tmpB + E_U_nl_k(1,ii); 330 | end 331 | E_T_2 = E_T_2 + 2 * tmpA * tmpB; 332 | end 333 | end 334 | 335 | for nn = 1:N_RIS 336 | tmpC = 0; 337 | for kk = 1:L(nn) 338 | tmpC = tmpC + E_U_nl_k(2,nn); 339 | end 340 | tmpD = 0; 341 | for kk = 1:L(nn) 342 | for v = (kk+1):L(nn) 343 | tmpD = tmpD + 2 * E_U_nl_k(1,nn) * E_U_nl_k(1,nn); 344 | end 345 | end 346 | E_T_2 = E_T_2 + tmpC + tmpD; 347 | end 348 | 349 | % Working on Z 350 | %------------ 351 | 352 | % The 1st moment of Z 353 | E_Z_1 = E_h0_k(1) + E_T_1; 354 | 355 | % The 2nd moment of Z in ERA 356 | E_Z_2 = E_h0_k(2) + E_T_2 + 2*E_h0_k(1)*E_T_1; 357 | 358 | % Parameter of the approximate Gamma distribution of Z 359 | alpha_Z = E_Z_1^2/(E_Z_2 - E_Z_1^2); 360 | beta_Z = E_Z_1/(E_Z_2 - E_Z_1^2); 361 | 362 | % CDF of Z in ERA 363 | F_Z_Gamma = @(z) gammainc(z*beta_Z, alpha_Z, 'lower'); 364 | 365 | % PDF of Z in ERA 366 | f_Z_Gamma = @(z) 1/gamma(alpha_Z)*(beta_Z)^alpha_Z... 367 | * z.^(alpha_Z-1) .* exp( -z*beta_Z ); 368 | 369 | % CDF of Z^2 in ERA 370 | F_Z2_Gamma = @(z) F_Z_Gamma(sqrt(z)); 371 | 372 | % Asymptotic analysis 373 | %-------------------- 374 | 375 | % %Asymptotic CDF of Z 376 | % F_Z_Gamma_asymp = @(z) (z*beta_Z)^alpha_Z/gamma(alpha_Z+1); 377 | % 378 | % %Asymptotic CDF of Z^2 379 | % F_Z2_Gamma_asymp= @(z) F_Z_Gamma_asymp(sqrt(z)); 380 | 381 | %% ANALYSIS | ORA SCHEME | GAMMA DISTRIBUTION 382 | 383 | % Working on M_V ( max V_n ) 384 | %--------------------------- 385 | 386 | % CDF of V_M in ORA 387 | F_M_V = @(x) 1; 388 | for k = 1:N_RIS 389 | F_M_V = @(x) F_M_V(x) .* F_V_n(x,k); 390 | end 391 | 392 | M = 100; %Number of steps in M-staircase approximation 393 | 394 | % CDF of R in ORA 395 | F_R = @(r) 0; 396 | for m = 1:M 397 | F_R = @(r) F_R(r)... 398 | + (F_h0(m/M*r) - F_h0((m-1)/M*r)) .* F_M_V((M-m+1)/M*r); 399 | end 400 | 401 | % CDF of R^2 in ORA 402 | F_R2_Gamma = @(r) F_R(sqrt(r)); % for using in e2e SNR of the ORA scheme 403 | 404 | % Asymptotic analysis 405 | %-------------------- 406 | 407 | % %Asymptotic of R^2 408 | % LAlpha_arr = zeros(1,N_RIS); 409 | % Beta_arr = zeros(1,N_RIS); 410 | % 411 | % for n = 1:N_RIS 412 | % LAlpha_arr(n) = L(n)*alpha_U(n); 413 | % Beta_arr(n) = beta_U(n); 414 | % end 415 | % 416 | % M1 = 1e3; m_arr = 1:M1; 417 | % fM = sum( ((m_arr-1)/M1).^(2*m0-1).*(1-(m_arr-1)/M1).^sum(LAlpha_arr) )/M1; 418 | % 419 | % F_R_Gamma_asymp = @(r) (2*m0)/gamma(m0+1)*(m0/Omg0)^(m0)... 420 | % * prod( Beta_arr.^(LAlpha_arr) ./ gamma(LAlpha_arr+1) .* r.^LAlpha_arr )... 421 | % * r.^(2*m0) * fM; 422 | % F_R2_asymp = @(r) F_R_Gamma_asymp(sqrt(r)); 423 | 424 | %% CDF of Z | ERA SCHEME | GAMMA DISTRIBUTION 425 | 426 | figure; 427 | 428 | [y, x] = ecdf(Z_ERA); hold on; 429 | domain_Z = linspace(0, max(x), 30); 430 | 431 | plot(x, y); hold on; 432 | plot(domain_Z, F_Z_Gamma(domain_Z), '.', 'markersize', 10); hold on; 433 | 434 | title('CDF of Z | ERA SCHEME | GAMMA DISTRIBUTION') 435 | xlabel('$x$', 'Interpreter', 'Latex') 436 | ylabel('CDF','Interpreter', 'Latex') 437 | legend('True',... 438 | 'Approx.',... 439 | 'location', 'se',... 440 | 'Interpreter', 'Latex'); 441 | 442 | % x0 = 100; y0 = 100; width = 300; height = 250; 443 | % set(gcf,'Position', [x0, y0, width, height]); % plot size 444 | set(gca, 'LooseInset', get(gca, 'TightInset')) % remove plot padding 445 | set(gca,'fontsize',13); 446 | 447 | %% PDF of Z | ERA SCHEME | GAMMA DISTRIBUTION 448 | 449 | % Non-symbolic PDF of Z and Z^2 450 | %------------------------------ 451 | 452 | % f_Z = @(z) 1/gamma(alpha_Z)*(beta_Z)^alpha_Z... 453 | % * z.^(alpha_Z-1) .* exp( -z*beta_Z ); 454 | % f_Z2 = @(z) 1./(2*sqrt(z)) .* f_Z(sqrt(z)); 455 | 456 | figure; 457 | 458 | number_of_bins = 30; 459 | histogram(h_ERA_e2e_magnitude, number_of_bins, 'normalization', 'pdf'); hold on; 460 | % histfit(h_ERA_e2e_magnitude, number_of_bins, 'gamma'); hold on; 461 | 462 | % Symbolic PDF of Z 463 | syms sbl_az sbl_bz sbl_z 464 | symbolic_f_Z(sbl_az,sbl_bz,sbl_z) = 1/gamma(sbl_az)*(sbl_bz)^sbl_az ... 465 | * sbl_z^(sbl_az-1) * exp( - sbl_z*sbl_bz ); 466 | 467 | plot(domain_Z, double(vpa(symbolic_f_Z(alpha_Z, beta_Z, domain_Z))),... 468 | 'linewidth', 1); hold on; 469 | 470 | title('PDF of Z | ERA SCHEME | GAMMA DISTRIBUTION') 471 | xlabel('$x$', 'Interpreter', 'Latex') 472 | ylabel('PDF', 'Interpreter', 'Latex') 473 | legend('True',... 474 | 'Approx.',... 475 | 'location', 'ne',... 476 | 'Interpreter', 'Latex'); 477 | 478 | set(gca, 'LooseInset', get(gca, 'TightInset')) % remove plot padding 479 | set(gca,'fontsize',13); 480 | 481 | %% CDF of R | ORA SCHEME | GAMMA DISTRIBUTION 482 | 483 | figure; 484 | 485 | [y, x] = ecdf(R_ORA); hold on; 486 | domain_R = linspace(0, max(x), 30); 487 | 488 | plot(x, y); hold on; 489 | plot(domain_R, F_R(domain_R), '.', 'markersize', 10); hold on; 490 | 491 | title('CDF of R | ORA SCHEME | GAMMA DISTRIBUTION') 492 | xlabel('$x$', 'Interpreter', 'Latex') 493 | ylabel('CDF', 'Interpreter', 'Latex') 494 | legend('True',... 495 | 'Approx.',... 496 | 'location', 'se',... 497 | 'Interpreter', 'Latex'); 498 | 499 | set(gca, 'LooseInset', get(gca, 'TightInset')) %remove plot padding 500 | set(gca,'fontsize',13); 501 | 502 | %% PDF of R | ORA SCHEME | GAMMA DISTRIBUTION 503 | 504 | f_M_V = @(x) 0; % CDF of M_v in ORA 505 | 506 | for nn = 1:N_RIS 507 | func_tmp = @(x) 1; 508 | for t = 1:N_RIS 509 | if (nn ~= t) 510 | func_tmp = @(x) func_tmp(x) .* F_V_n(x,t); 511 | end 512 | end 513 | f_M_V = @(x) f_M_V(x) + f_V_n(x,nn) .* func_tmp(x); 514 | end 515 | 516 | M = 100; %Number of steps in M-staircase approximation 517 | 518 | f_R = @(r) 0; % PDF of R in ORA 519 | 520 | 521 | for m = 1:M 522 | f_R = @(r) f_R(r)... 523 | + ((m/M)*f_h0(m/M*r) - ((m-1)/M)*f_h0((m-1)/M*r))... 524 | .*F_M_V((M-m+1)/M*r)... 525 | + (F_h0(m/M*r)- F_h0((m-1)/M*r))... 526 | .*((M-m+1)/M).*f_M_V((M-m+1)/M*r); 527 | end 528 | 529 | f_R2 = @(r) 1./(2*sqrt(r)).*f_R(sqrt(r)); % PDF of R^2 in ORA 530 | 531 | figure; 532 | 533 | histogram(R_ORA, number_of_bins, 'normalization', 'pdf'); hold on; 534 | plot(domain_R, double(vpa(f_R(sym(domain_R)))), 'linewidth', 1.5); hold on; 535 | 536 | title('PDF of R | ORA SCHEME | GAMMA DISTRIBUTION') 537 | xlabel('$x$', 'Interpreter', 'Latex') 538 | ylabel('PDF', 'Interpreter', 'Latex') 539 | legend('True ',... 540 | 'Approx.',... 541 | 'location', 'ne',... 542 | 'Interpreter', 'Latex'); 543 | 544 | set(gca, 'LooseInset', get(gca, 'TightInset')) %remove plot padding 545 | set(gca,'fontsize',13); 546 | 547 | %% OUTAGE PROBABILITY 548 | 549 | OP_non_RIS_sim = zeros(length(SNRdB),1); % should be column vector 550 | OP_ERA_sim = zeros(length(SNRdB),1); 551 | OP_ERA_ana = zeros(length(SNRdB),1); 552 | OP_ORA_sim = zeros(length(SNRdB),1); 553 | OP_ORA_ana = zeros(length(SNRdB),1); 554 | 555 | SNR_h0 = abs(h_SD).^2; 556 | 557 | for idx = 1:length(SNRdB) 558 | 559 | avgSNR = db2pow(SNRdB(idx)); % i.e., 10^(SNRdB/10) 560 | 561 | OP_non_RIS_sim(idx) = mean(avgSNR*SNR_h0 < SNR_th); 562 | 563 | % ERA scheme 564 | 565 | OP_ERA_sim(idx) = mean(avgSNR*Z2_ERA < SNR_th); 566 | 567 | OP_ERA_ana(idx) = F_Z2_Gamma(SNR_th/avgSNR); 568 | 569 | %ORA scheme 570 | 571 | OP_ORA_sim(idx) = mean(avgSNR*R2_ORA < SNR_th); 572 | 573 | OP_ORA_ana(idx) = F_R2_Gamma(SNR_th/avgSNR); 574 | 575 | fprintf('Outage probability, SNR = % d \n', round(SNRdB(idx))); 576 | end 577 | 578 | figure; 579 | 580 | semilogy(P_S_dB, OP_non_RIS_sim, 'b+-'); hold on; 581 | semilogy(P_S_dB, OP_ERA_sim, 'ro:'); hold on; 582 | semilogy(P_S_dB, OP_ERA_ana, 'r-'); hold on; 583 | semilogy(P_S_dB, OP_ORA_sim, 'b^:'); hold on; 584 | semilogy(P_S_dB, OP_ORA_ana, 'b-'); hold on; 585 | 586 | xlabel('$P_{\rm S}$ [dBm]', 'Interpreter', 'Latex'); 587 | ylabel('Outage probability, $P_{\rm out}$', 'Interpreter', 'Latex'); 588 | legend('Non-RIS (sim.)',... 589 | 'ERA (sim.)', ... 590 | 'ERA (ana. with Gamma)',... 591 | 'ORA (sim.)', ... 592 | 'ORA (ana. with Gamma)',... 593 | 'Location','se',... 594 | 'Interpreter', 'Latex'); 595 | axis([-Inf Inf 10^(-5) 10^(0)]); 596 | 597 | %% ERGODIC CAPACITY 598 | 599 | EC_non_RIS_sim = zeros(length(SNRdB),1); % should be column vector 600 | EC_ERA_sim = zeros(length(SNRdB),1); 601 | EC_ERA_ana = zeros(length(SNRdB),1); 602 | EC_ORA_sim = zeros(length(SNRdB),1); 603 | EC_ORA_ana = zeros(length(SNRdB),1); 604 | 605 | syms az bz rho % Inputs: az = alpha_Z, bz = beta_Z, rho = snr 606 | 607 | EC_RIS(az, bz, rho) = 1/gamma(az)/log(2)*2^(az-1)/sqrt(pi)... 608 | * meijerG(0, [1/2,1], [az/2,az/2+1/2,0,0,1/2], [], (bz/2)^2/rho); 609 | 610 | func_EC_ORA_Gamma = @(x,c) (1/log(2)).*(1./(1+x).*(1 - F_R(sqrt(x./c)))); 611 | 612 | for idx = 1:length(SNRdB) 613 | avgSNR = db2pow(SNRdB(idx)); % 10^(SNRdB(idx)/10) 614 | 615 | EC_non_RIS_sim(idx) = mean(log2(1 + avgSNR*SNR_h0)); 616 | 617 | EC_ERA_sim(idx) = mean(log2(1+avgSNR*Z2_ERA)); 618 | 619 | EC_ERA_ana(idx) = double(vpa(EC_RIS(alpha_Z, beta_Z, avgSNR))); 620 | 621 | EC_ORA_sim(idx) = mean(log2(1+avgSNR*R2_ORA)); 622 | 623 | EC_ORA_ana(idx) = integral(@(x) func_EC_ORA_Gamma(x,avgSNR), 0, Inf); 624 | 625 | fprintf('Ergodic capacity, SNR = % d \n', round(SNRdB(idx))); 626 | end 627 | 628 | figure; 629 | 630 | plot(P_S_dB, EC_non_RIS_sim, 'b+-'); hold on; 631 | plot(P_S_dB, EC_ERA_sim, 'ro:'); hold on; 632 | plot(P_S_dB, EC_ERA_ana, 'r-'); hold on; 633 | plot(P_S_dB, EC_ORA_sim, 'bs:'); hold on; 634 | plot(P_S_dB, EC_ORA_ana, 'b-'); hold on; 635 | 636 | xlabel('$P_{\rm S}$ [dBm]', 'Interpreter', 'Latex'); 637 | ylabel('Ergodic capacity [b/s/Hz]', 'Interpreter', 'Latex'); 638 | legend('Non-RIS (sim.)',... 639 | 'ERA (sim.)',... 640 | 'ERA (ana. with Gamma)',... 641 | 'ORA (sim.)',... 642 | 'ORA (analytical)',... 643 | 'Interpreter', 'Latex',... 644 | 'Location','NW'); 645 | 646 | toc 647 | -------------------------------------------------------------------------------- /main_FULL_LogNormal.m: -------------------------------------------------------------------------------- 1 | %% PAPER 2 | 3 | % Title: Multi-RIS-aided Wireless Systems: Statistical Characterization and Performance Analysis 4 | % Authors : Tri Nhu Do, Georges Kaddoum, Thanh Luan Nguyen, Daniel Benevides da Costa, Zygmunt J. Haas 5 | % Online: https://github.com/trinhudo/Multi-RIS 6 | % Version: 12-Sep-2021 7 | 8 | % Multiple RISs with detailed phase-shift configuration 9 | % --ERA scheme: all RISs participate 10 | % --ORA scheme: only the best RIS participates 11 | % --Analysis is based on Log-Normal distribution 12 | 13 | tic 14 | % rng('default'); 15 | 16 | %% SETTING 17 | 18 | clear all 19 | close all 20 | 21 | sim_times = 1e5; % Number of simulation trails 22 | 23 | R_th = 1; % Predefined target spectral efficiency [b/s/Hz] 24 | 25 | SNR_th = 2^R_th-1; % Predefined SNR threshold 26 | 27 | N_RIS = 5; % Number of distributed RISs 28 | 29 | L_single = 25; % Number of elements at each RIS 30 | 31 | L = L_single*ones(1,N_RIS); % all RISs 32 | 33 | kappa_nl = 1; % Amplitude reflection coefficient 34 | 35 | % Network area 36 | x_area_min = 0; 37 | x_area_max = 100; % in meters 38 | y_area_min = 0; 39 | y_area_max = 10; 40 | 41 | % Source location 42 | x_source = x_area_min; 43 | y_source = y_area_min; 44 | 45 | % Destination location 46 | x_des = x_area_max; 47 | y_des = y_area_min; 48 | 49 | % Random location setting 50 | % x_RIS = x_area_min + (x_area_max-x_area_min)*rand(N_RIS, 1); % [num_RIS x 1] vector 51 | % y_RIS = y_area_min + (y_area_max-y_area_min)*rand(N_RIS, 1); 52 | 53 | %Location setting D1 54 | x_RIS = [7; 13; 41; 75; 93]; 55 | y_RIS = [2; 6; 8; 4; 3]; 56 | 57 | % Compute location of nodes 58 | pos_source = [x_source, y_source]; 59 | 60 | pos_des = [x_des, y_des]; 61 | pos_RIS = [x_RIS, y_RIS]; % [num_RIS x 2] matrix 62 | 63 | % Compute distances 64 | d_SR = sqrt(sum((pos_source - pos_RIS).^2 , 2)); % [num_RIS x 1] vector 65 | d_RD = sqrt(sum((pos_RIS - pos_des).^2 , 2)); 66 | d_SD = sqrt(sum((pos_source - pos_des).^2 , 2)); 67 | 68 | %% NETWORK TOPOLOGY 69 | 70 | figure; 71 | 72 | scatter(x_source, y_source, 100, 'b^', 'filled'); hold on 73 | scatter(x_des, y_des, 100, 'go', 'filled'); hold on 74 | scatter(x_RIS, y_RIS, 100, 'rs', 'filled'); hold on 75 | 76 | for kk = 1:N_RIS 77 | text(x_RIS(kk)+3, y_RIS(kk)+0.1, num2str(kk)); 78 | hold on 79 | end 80 | 81 | xlabel('$d_{\rm SD}$ (m)', 'Interpreter', 'Latex') 82 | ylabel('$H$ (m)', 'Interpreter', 'Latex') 83 | axis([x_area_min x_area_max y_area_min y_area_max]) 84 | legend('$\rm S$', '$\rm D$', '$\mathrm{R}_i$',... 85 | 'Interpreter', 'Latex',... 86 | 'Location', 'best') 87 | 88 | set(gca, 'LooseInset', get(gca, 'TightInset')) % remove plot padding 89 | set(gca,'fontsize',13); 90 | hold off 91 | 92 | % Path-loss model 93 | % --------------- 94 | % Following: https://github.com/emilbjornson/IRS-relaying 95 | 96 | % Carrier frequency (in GHz) 97 | fc = 3; % GHz 98 | 99 | % 3GPP Urban Micro in 3GPP TS 36.814 100 | % NLoS path-loss component based on distance, x is in meter 101 | pathloss_NLOS = @(x) db2pow(-22.7 - 26*log10(fc) - 36.7*log10(x)); 102 | 103 | antenna_gain_S = db2pow(5); % Source antenna gain, dBi 104 | antenna_gain_RIS = db2pow(5); % Gain of each element of a RIS, dBi 105 | antenna_gain_D = db2pow(0); % Destination antenna gain, dBi 106 | 107 | % Noise power and Transmit power P_S 108 | % ---------------------------------- 109 | 110 | % Bandwidth 111 | BW = 10e6; % 10 MHz 112 | 113 | % Noise figure (in dB) 114 | noiseFiguredB = 10; 115 | 116 | % Compute the noise power in dBm 117 | sigma2dBm = -174 + 10*log10(BW) + noiseFiguredB; % -94 dBm 118 | sigma2 = db2pow(sigma2dBm); 119 | 120 | P_S_dB = -5:25; % Transmit power of the source, dBm, e.g., 200mW = 23dBm 121 | 122 | SNRdB = P_S_dB - sigma2dBm; % Average transmit SNR, dB = dBm - dBm, bar{rho} = P_S / sigma2 123 | 124 | %% SIMULATION | ERA SCHEME 125 | 126 | % Nakagami scale parameter 127 | m_0 = 2.5 + rand; % S -> D, scale parameter, heuristic setting 128 | 129 | m_h = 2.5 + rand(N_RIS, 1); % S -> RIS 130 | 131 | m_g = 2.5 + rand(N_RIS, 1); % RIS -> D 132 | 133 | % Nakagami spread parameter 134 | 135 | Omega_0 = 1; % Normalized spread parameter of S->D link 136 | Omega_h = 1; % Normalized spread parameter of S->RIS link 137 | Omega_g = 1; % Normalized spread parameter of RIS->D link 138 | 139 | % Path-loss 140 | 141 | path_loss_0 = pathloss_NLOS(d_SD)*antenna_gain_S; % S -> D link 142 | 143 | path_loss_h = pathloss_NLOS(d_SR) * ... 144 | antenna_gain_S*antenna_gain_RIS*L_single; % S -> RIS 145 | 146 | path_loss_g = pathloss_NLOS(d_RD) * ... 147 | antenna_gain_RIS*L_single*antenna_gain_D; % RIS -> D 148 | 149 | % Phase of channels 150 | 151 | phase_h_SD = 2*pi*rand(1, sim_times); % domain [0,2pi) 152 | phase_h_SR = 2*pi*rand(N_RIS, L_single, sim_times); % domain [0,2pi) 153 | phase_g_RD = 2*pi*rand(N_RIS, L_single, sim_times); % domain [0,2pi) 154 | 155 | phase_h_SR_eachRIS = zeros(L_single, sim_times); 156 | phase_g_RD_eachRIS = zeros(L_single, sim_times); 157 | 158 | % Channel modeling 159 | 160 | h_SD = sqrt(path_loss_0) * ... % need sqrt because path-loss is outside of random() 161 | random('Naka', m_0, Omega_0, [1, sim_times]) .* ... 162 | exp(1i*phase_h_SD); 163 | 164 | h_SR = zeros(N_RIS,L_single,sim_times); % S to RIS channel 165 | g_RD = zeros(N_RIS,L_single,sim_times); % RIS to D channel 166 | 167 | for nn = 1:N_RIS 168 | phase_h_SR_eachRIS = squeeze(phase_h_SR(nn,:,:)); % random() just uses 2D 169 | phase_g_RD_eachRIS = squeeze(phase_g_RD(nn,:,:)); % random() just uses 2D 170 | 171 | for kk=1:L(nn) 172 | h_SR(nn,kk,:) = sqrt(path_loss_h(nn)) .* ... % need sqrt because path-loss is outside of random() 173 | random('Naka', m_h(nn), Omega_h, [1, sim_times]) .* ... 174 | exp(1i*phase_h_SR_eachRIS(kk,:)); 175 | 176 | g_RD(nn,kk,:) = sqrt(path_loss_g(nn)) .* ... % need sqrt because path-loss is outside of random() 177 | random('Naka', m_g(nn), Omega_g, [1, sim_times]) .* ... 178 | exp(1i*phase_g_RD_eachRIS(kk,:)); 179 | end 180 | end 181 | 182 | % Phase-shift Configuration for ERA scheme 183 | %----------------------------------------- 184 | 185 | h_ERA_cascade = zeros(N_RIS, sim_times); % matrix of cascade channel S-via-RIS-to-D 186 | 187 | for ss = 1:sim_times % loop over simulation trials 188 | phase_shift_config_ideal = zeros(L_single,1); 189 | phase_shift_config_ideal_normalized = zeros(L_single,1); 190 | phase_shift_complex_vector = zeros(L_single,1); 191 | 192 | for nn=1:N_RIS % loop over each RIS 193 | for ll = 1:L_single % loop over each elements of one RIS 194 | % Unknown domain phase-shift 195 | phase_shift_config_ideal(ll) = ... 196 | phase_h_SD(ss) - phase_h_SR(nn,ll,ss) - phase_g_RD(nn,ll,ss); 197 | % Convert to domain of [0, 2pi) 198 | phase_shift_config_ideal_normalized(ll) = wrapTo2Pi(phase_shift_config_ideal(ll)); 199 | phase_shift_complex_vector(ll) = exp(1i*phase_shift_config_ideal_normalized(ll)); 200 | end 201 | 202 | phase_shift_matrix = kappa_nl .* diag(phase_shift_complex_vector); 203 | 204 | % cascade channel (complex, not magnitude) 205 | h_ERA_cascade(nn,ss) = h_SR(nn,:,ss) * phase_shift_matrix * g_RD(nn,:,ss).'; % returns a number 206 | end 207 | end 208 | 209 | h_ERA_e2e_magnitude = abs(h_SD + sum(h_ERA_cascade,1)); % direct + cascade channels 210 | 211 | Z_ERA = h_ERA_e2e_magnitude; % RV Z in the analysis 212 | 213 | Z2_ERA = Z_ERA.^2; % RV Z^2 214 | 215 | %% SIMULATION | ORA SCHEME (BEST RIS SELECTION) 216 | 217 | % Simple simulation 218 | %------------------ 219 | 220 | % V_M_ORA = max(h_e2e_RIS_path, [], 1); %V_M for the best RIS 221 | % R_ORA = abs(h_SD + V_M_ORA); %Magnitude of the e2e channel 222 | % R2_ORA = R_ORA.^2; %Squared magnitude of the e2e channel 223 | 224 | % Detailed simulation 225 | %-------------------- 226 | 227 | h_ORA_cascade = zeros(1, sim_times); 228 | 229 | [~,idx] = max(h_ERA_cascade,[],1); 230 | 231 | for ss = 1:sim_times 232 | phase_shift_config_ideal = zeros(L_single,1); 233 | phase_shift_config_ideal_normalized = zeros(L_single,1); 234 | phase_shift_complex_vector = zeros(L_single,1); 235 | for ll = 1:L_single % loop over each elements of one RIS 236 | phase_shift_config_ideal(ll) = phase_h_SD(ss) - phase_h_SR(idx(ss),ll,ss) - phase_g_RD(idx(ss),ll,ss); 237 | phase_shift_config_ideal_normalized(ll) = wrapTo2Pi(phase_shift_config_ideal(ll)); 238 | phase_shift_complex_vector(ll) = exp(1i*phase_shift_config_ideal_normalized(ll)); 239 | end 240 | 241 | phase_shift_matrix = kappa_nl .* diag(phase_shift_complex_vector); 242 | 243 | % e2e channel coefficient (complex number, not magnitude) 244 | h_ERA_cascade(idx(ss),ss) = h_SR(idx(ss),:,ss) * phase_shift_matrix * g_RD(idx(ss),:,ss).'; 245 | 246 | h_ORA_cascade(ss) = h_ERA_cascade(idx(ss),ss); 247 | end 248 | 249 | h_ORA_e2e_magnitude = abs(h_SD + h_ORA_cascade); 250 | 251 | R_ORA = h_ORA_e2e_magnitude; % RV R in the analysis 252 | 253 | R2_ORA = h_ORA_e2e_magnitude.^2; % RV R^2 254 | 255 | %% ANALYSIS | ERA SCHEME | LOG-NORMAL DISTRIBUTION 256 | 257 | Omg_0 = Omega_0*path_loss_0; 258 | Omg_h = Omega_h*path_loss_h; 259 | Omg_g = Omega_g*path_loss_g; 260 | 261 | lambda = sqrt(m_h./Omg_h .* m_g./Omg_g) ./ kappa_nl; % lambda_nl 262 | 263 | % Working on h0 264 | %-------------- 265 | 266 | % Working on h0 267 | % The k-th moment of h0 268 | E_h0_k = @(k) gamma(m_0+k/2)/gamma(m_0)*(m_0/Omg_0)^(-k/2); 269 | 270 | F_h0 = @(x) gammainc(m_0*x.^2/Omg_0, m_0, 'lower'); 271 | 272 | % Working on U_nl 273 | %---------------- 274 | 275 | % The k-moment of U_nl 276 | E_U_nl_k = @(k, n) lambda(n)^(-k)*gamma(m_h(n)+0.5*k)... 277 | * gamma(m_g(n)+0.5*k) / gamma(m_h(n)) / gamma(m_g(n)); 278 | 279 | % Parameter of the approximate Gamma distribution of U_nl 280 | alpha_U = @(n) E_U_nl_k(1, n)^2/(E_U_nl_k(2, n)-E_U_nl_k(1, n)^2); 281 | beta_U = @(n) E_U_nl_k(1, n)/(E_U_nl_k(2, n)-E_U_nl_k(1, n)^2); 282 | 283 | % Working on V_n 284 | %--------------- 285 | 286 | % The k-moment of V_n 287 | E_V_n_k = @(k, n) gamma(L(n) * alpha_U(n)+k) ... 288 | / gamma(L(n) * alpha_U(n)) * beta_U(n)^(-k); 289 | 290 | % Working on T 291 | %------------- 292 | 293 | %The 1st moment of T 294 | E_T1 = 0; 295 | for n = 1:N_RIS 296 | for l = 1:L(n) 297 | E_T1 = E_T1 + E_U_nl_k(1, n); 298 | end 299 | end 300 | 301 | %The 2nd moment of T 302 | E_T2 = 0; 303 | for n = 1:N_RIS 304 | tmpA = 0; 305 | for l = 1:L(n) 306 | tmpA = tmpA + E_U_nl_k(1, n); 307 | end 308 | for ii = n+1:N_RIS 309 | tmpB = 0; 310 | for l = 1:L(ii) 311 | tmpB = tmpB + E_U_nl_k(1, ii); 312 | end 313 | E_T2 = E_T2 + 2 * tmpA * tmpB; 314 | end 315 | end 316 | 317 | for n = 1:N_RIS 318 | tmpC = 0; 319 | for l = 1:L(n) 320 | tmpC = tmpC + E_U_nl_k(2, n); 321 | end 322 | tmpD = 0; 323 | for l = 1:L(n) 324 | for v = (l+1):L(n) 325 | tmpD = tmpD + 2 * E_U_nl_k(1, n) * E_U_nl_k(1, n); 326 | end 327 | end 328 | E_T2 = E_T2 + tmpC + tmpD; 329 | end 330 | 331 | E_Z = E_h0_k(1) + E_T1; % 1st moment 332 | 333 | E_Z2 = E_h0_k(2) + E_T2 + 2 * E_h0_k(1) * E_T1; % 2nd moment 334 | 335 | % Fit Z_ERA to Log-Normal 336 | %------------------------- 337 | 338 | E_Z4 = 0; % the 2nd moment of Z^2, i.e., E[(Z^2)^2], 4th moment of Z 339 | for k = 0:4 340 | E_Tk = 0; % E[T^k] % the k-th momemt of T >> CAN BE USE IN ERA ??? 341 | [cases_T, indT_mat] = nsumk(N_RIS, k); 342 | for icaseT = 1:cases_T 343 | indT_arr = indT_mat(icaseT, :); 344 | tmpT = 1; 345 | for t = 1:N_RIS 346 | tmpT = tmpT * E_V_n_k(indT_arr(t), t); 347 | end 348 | E_Tk = E_Tk + factorial(k)/prod( factorial(indT_arr) ) * tmpT; 349 | end 350 | E_Z4 = E_Z4 + nchoosek(4, k)*E_h0_k(4-k)*E_Tk; 351 | end 352 | 353 | nu_Z2_ERA_LN = log( E_Z2^2/sqrt(E_Z4) ); % for Z2 in ERA, used in EC 354 | zeta2_Z2_ERA_LN = log( E_Z4/E_Z2^2 ); % for Z2 in ERA, used in EC 355 | 356 | nu_Z_ERA_LN = log(E_Z^2 / sqrt(E_Z2) ); % for Z in ERA 357 | zeta2_Z_ERA_LN = log( E_Z2 / (E_Z^2) ); % for Z in ERA 358 | 359 | % CDF of Z 360 | F_Z_ERA_new = ... 361 | @(x) 1/2 + 1/2*erf( (log(x)-nu_Z_ERA_LN)/sqrt(2*zeta2_Z_ERA_LN) ); 362 | 363 | % CDF of Z^2 364 | F_Z2_ERA_LN = ... 365 | @(x) 1/2 + 1/2*erf( (log(x)-nu_Z2_ERA_LN)/sqrt(2*zeta2_Z2_ERA_LN) ); 366 | 367 | %% ANALYSIS | ORA SCHEME | LOG-NORMAL DISTRIBUTION 368 | 369 | alpha_U_arr = zeros(1, N_RIS); 370 | beta_U_arr = zeros(1, N_RIS); 371 | 372 | for n = 1:N_RIS 373 | alpha_U_arr(n) = alpha_U(n); 374 | beta_U_arr(n) = beta_U(n); 375 | end 376 | % 377 | chi_t= @(t) beta_U_arr(t) ./ sum(beta_U_arr); 378 | 379 | % Approxiate result, using self-built F_A() function 380 | %--------------------------------------------------- 381 | 382 | alpha_U_arr= zeros(1, N_RIS); 383 | beta_U_arr = zeros(1, N_RIS); 384 | for n = 1:N_RIS 385 | alpha_U_arr(n) = alpha_U(n); 386 | beta_U_arr(n) = beta_U(n); 387 | end 388 | 389 | f_V_n = @(v, n) beta_U(n)^(L(n)*alpha_U(n))/gamma(L(n)*alpha_U(n))... 390 | * v.^(L(n)*alpha_U(n)-1) .* exp( -beta_U(n)*v ); 391 | F_V_n = @(v, n) gammainc(beta_U(n)*v, L(n)*alpha_U(n), 'lower'); 392 | 393 | f_M_V = @(x) 0; 394 | 395 | for n = 1:N_RIS 396 | func_tmp = @(x) 1; 397 | for t = 1:N_RIS 398 | if (n ~= t) 399 | func_tmp = @(x) func_tmp(x) .* F_V_n(x, t); 400 | end 401 | end 402 | f_M_V = @(x) f_M_V(x) + f_V_n(x, n) .* func_tmp(x); 403 | end 404 | 405 | % mu_M_V = zeros(1, 4); % the k-th moment of M_V (k = 1, 2, 3, 4) 406 | % for k = 1:4 407 | % mu_M_V(k) = integral(@(x) x.^k .* f_M_V(x), 0, 250); 408 | % end 409 | 410 | X = sym('X', [1, N_RIS]); 411 | mu_M_V = sym(zeros(1, 4)); % the k-th moment of M_V (k = 1, 2, 3, 4) 412 | for k = 1:4 413 | for n = 1:N_RIS 414 | % 415 | Sn = setdiff(1:N_RIS, n); 416 | % 417 | tmp = Lauricella_FA(sum(L.*alpha_U_arr)+k, ones(1, N_RIS-1), L(Sn).*alpha_U_arr(Sn)+1, chi_t(Sn)); 418 | % 419 | if (tmp > 0) 420 | mu_M_V(k) = mu_M_V(k) + gamma( sum(X)+k ) / gamma(X(n))... 421 | / prod( gamma(X(Sn)+1) ) * sym(tmp); 422 | end 423 | end 424 | mu_M_V(k) = vpa(subs(sum(beta_U_arr)^(-k) * prod( chi_t(1:N_RIS).^(X) ) * mu_M_V(k), X, L.*alpha_U_arr)); 425 | end 426 | mu_M_V = double(mu_M_V); 427 | 428 | 429 | E_R = 0; % E[R] 430 | for k = 0:1 431 | if k >= 1 432 | E_R = E_R + nchoosek(1, k) * E_h0_k(1-k) * mu_M_V(k); 433 | else 434 | E_R = E_R + E_h0_k(1); 435 | end 436 | end 437 | 438 | E_R_2 = 0; % E[R^2] by using R^2 expressions, not R 439 | for k = 0:2 440 | if k >= 1 441 | E_R_2 = E_R_2 + nchoosek(2, k) * E_h0_k(2-k) * mu_M_V(k); 442 | else 443 | E_R_2 = E_R_2 + E_h0_k(2); 444 | end 445 | end 446 | 447 | E_R_4 = 0; % E[(R^2)^2] by using R^2 expressions, not R 448 | for k = 0:4 449 | if k >= 1 450 | E_R_4 = E_R_4 + nchoosek(4, k) * E_h0_k(4-k) * mu_M_V(k); 451 | else 452 | E_R_4 = E_R_4 + E_h0_k(4); 453 | end 454 | end 455 | 456 | nu_R_ORA_LN = log( E_R^2/sqrt(E_R_2) ); % for R in ORA 457 | zeta2_R_ORA_LN = log( E_R_2/E_R^2 ); % for R in ORA 458 | 459 | nu_R2_ORA_LN = log( E_R_2^2/sqrt(E_R_4) ); % for R^2 in ORA 460 | zeta2_R2_ORA_LN = log( E_R_4/E_R_2^2 ); % for R^2 in ORA 461 | 462 | F_R_ORA_LN = @(x) 1/2 + ... 463 | 1/2*erf( (log(x)-nu_R_ORA_LN)/sqrt(2*zeta2_R_ORA_LN) ); % CDF of R 464 | 465 | F_R2_ORA_LN = @(x) 1/2 + ... 466 | 1/2*erf( (log(x)-nu_R2_ORA_LN)/sqrt(2*zeta2_R2_ORA_LN) ); % CDF of R^2 467 | 468 | 469 | %% CDF of Z | ERA SCHEME | LOG-NORMAL DISTRIBUTION 470 | 471 | figure; 472 | 473 | [y, x] = ecdf(Z_ERA); hold on; 474 | domain_Z = linspace(0, max(x), 30); 475 | 476 | plot(x, y); hold on; 477 | plot(domain_Z, F_Z_ERA_new(domain_Z), '.', 'markersize', 10); hold on; 478 | 479 | title('CDF of Z | ERA SCHEME | LOG-NORMAL DISTRIBUTION') 480 | xlabel('$x$', 'Interpreter', 'Latex') 481 | ylabel('CDF','Interpreter', 'Latex') 482 | legend('True',... 483 | 'Approx.',... 484 | 'location', 'se',... 485 | 'Interpreter', 'Latex'); 486 | 487 | set(gca, 'LooseInset', get(gca, 'TightInset')) % remove plot padding 488 | set(gca,'fontsize',13); 489 | 490 | %% PDF of Z | ERA SCHEME | LOG-NORMAL DISTRIBUTION 491 | 492 | figure; 493 | 494 | f_Z_ERA_new = @(x) 1./(x .* sqrt(2*pi*zeta2_Z_ERA_LN) )... 495 | .* exp( -(log(x) - nu_Z_ERA_LN).^2./(2*zeta2_Z_ERA_LN) ); % PDF of Z 496 | 497 | f_Z2_ERA_LN = @(x) 1./(x .* sqrt(2*pi*zeta2_Z2_ERA_LN) )... 498 | .* exp( -(log(x) - nu_Z2_ERA_LN).^2./(2*zeta2_Z2_ERA_LN) ); % PDF of Z^2 499 | 500 | number_of_bins = 30; 501 | histogram(Z_ERA, number_of_bins, 'normalization', 'pdf'); hold on; 502 | 503 | plot(domain_Z, double(vpa(f_Z_ERA_new(sym(domain_Z)))), 'linewidth', 1); hold on; 504 | 505 | title('CDF of Z | ERA SCHEME | LOG-NORMAL DISTRIBUTION') 506 | xlabel('$x$', 'Interpreter', 'Latex') 507 | ylabel('PDF', 'Interpreter', 'Latex') 508 | legend('True',... 509 | 'Approx.',... 510 | 'location', 'ne',... 511 | 'Interpreter', 'Latex'); 512 | 513 | set(gca, 'LooseInset', get(gca, 'TightInset')) %remove plot padding 514 | set(gca,'fontsize',13); 515 | 516 | %% CDF of R | ORA SCHEME | LOG-NORMAL DISTRIBUTION 517 | 518 | figure; 519 | 520 | [y, x] = ecdf(R_ORA); hold on; 521 | domain_R = linspace(0, max(x), 30); 522 | plot(x, y); hold on; 523 | plot(domain_R, F_R_ORA_LN(domain_R), '.', 'markersize', 10); hold on; 524 | 525 | title('CDF of R | ORA SCHEME | LOG-NORMAL DISTRIBUTION') 526 | xlabel('$x$', 'Interpreter', 'Latex') 527 | ylabel('CDF', 'Interpreter', 'Latex') 528 | 529 | legend('True',... 530 | 'Approx.',... 531 | 'location', 'se',... 532 | 'Interpreter', 'Latex'); 533 | 534 | set(gca, 'LooseInset', get(gca, 'TightInset')) %remove plot padding 535 | set(gca,'fontsize',13); 536 | 537 | %% PDF of R | ORA SCHEME | LOG-NORMAL DISTRIBUTION 538 | 539 | figure; 540 | 541 | f_R_ORA_LN = @(x) 1./(x .* sqrt(2*pi*zeta2_R_ORA_LN) )... 542 | .* exp( -(log(x) - nu_R_ORA_LN).^2./(2*zeta2_R_ORA_LN) ); % CDF of R 543 | 544 | %PDF of R^2 545 | f_R2_ORA_LN = @(x) 1./(x .* sqrt(2*pi*zeta2_ORA_LN) )... 546 | .* exp( -(log(x) - nu_ORA_LN).^2./(2*zeta2_ORA_LN) ); 547 | 548 | number_of_bins = 30; 549 | 550 | histogram(R_ORA, number_of_bins, 'normalization', 'pdf'); hold on; 551 | plot(domain_R, double(vpa(f_R_ORA_LN(sym(domain_R)))), 'linewidth', 1.5); hold on; 552 | 553 | title('PDF of R | ORA SCHEME | LOG-NORMAL DISTRIBUTION') 554 | xlabel('$x$', 'Interpreter', 'Latex') 555 | ylabel('PDF', 'Interpreter', 'Latex') 556 | legend('True ',... 557 | 'Approx.',... 558 | 'location', 'ne',... 559 | 'Interpreter', 'Latex'); 560 | 561 | set(gca, 'LooseInset', get(gca, 'TightInset')) %remove plot padding 562 | set(gca,'fontsize',13); 563 | 564 | %% OUTAGE PROBABILITY | LOG-NORMAL DISTRIBUTION 565 | 566 | OP_non_RIS_sim = zeros(length(SNRdB),1); % should be column vector 567 | OP_ERA_sim = zeros(length(SNRdB),1); 568 | OP_ERA_ana = zeros(length(SNRdB),1); 569 | OP_ORA_sim = zeros(length(SNRdB),1); 570 | OP_ORA_ana = zeros(length(SNRdB),1); 571 | 572 | SNR_h0 = abs(h_SD).^2; 573 | 574 | for idx = 1:length(SNRdB) 575 | avgSNR = db2pow(SNRdB(idx)); % i.e., 10^(SNRdB/10) 576 | 577 | OP_non_RIS_sim(idx) = mean(avgSNR*SNR_h0 < SNR_th); 578 | 579 | % ERA scheme 580 | 581 | OP_ERA_sim(idx) = mean(avgSNR*Z2_ERA < SNR_th); 582 | 583 | OP_ERA_ana(idx) = F_Z_ERA_new(sqrt(SNR_th/avgSNR)); % F_Z (sqrt(x)) 584 | 585 | %ORA scheme 586 | 587 | OP_ORA_sim(idx) = mean(avgSNR*R2_ORA < SNR_th); 588 | 589 | OP_ORA_ana(idx) = F_R_ORA_LN(sqrt(SNR_th/avgSNR)); 590 | 591 | fprintf('Outage probability, SNR = % d \n', round(SNRdB(idx))); 592 | end 593 | 594 | figure; 595 | 596 | semilogy(P_S_dB, OP_non_RIS_sim, 'b+-'); hold on; 597 | semilogy(P_S_dB, OP_ERA_sim, 'ro:'); hold on; 598 | semilogy(P_S_dB, OP_ERA_ana, 'r-'); hold on; 599 | semilogy(P_S_dB, OP_ORA_sim, 'b^:'); hold on; 600 | semilogy(P_S_dB, OP_ORA_ana, 'b-'); hold on; 601 | 602 | xlabel('$P_{\rm S}$ [dBm]', 'Interpreter', 'Latex'); 603 | ylabel('Outage probability, $P_{\rm out}$', 'Interpreter', 'Latex'); 604 | legend('Non-RIS (sim.)',... 605 | 'ERA (sim.)', ... 606 | 'ERA (ana. with Gamma)',... 607 | 'ORA (sim.)', ... 608 | 'ORA (ana. with Gamma)',... 609 | 'Location','se',... 610 | 'Interpreter', 'Latex'); 611 | axis([-Inf Inf 10^(-5) 10^(0)]); 612 | 613 | %% ERGODIC CAPACITY | LOG-NORMAL DISTRIBUTION 614 | 615 | EC_non_RIS_sim = zeros(length(SNRdB),1); % should be column vector 616 | EC_ERA_sim = zeros(length(SNRdB),1); 617 | EC_ERA_ana = zeros(length(SNRdB),1); 618 | EC_ORA_sim = zeros(length(SNRdB),1); 619 | EC_ORA_ana = zeros(length(SNRdB),1); 620 | 621 | a1 = 0.9999964239; 622 | a2 = -0.4998741238; 623 | a3 = 0.3317990258; 624 | a4 = -0.2407338084; 625 | a5 = 0.1676540711; 626 | a6 = -0.0953293897; 627 | a7 = 0.0360884937; 628 | a8 = -0.0064535442; 629 | a_arr = [a1, a2, a3, a4, a5, a6, a7, a8]; 630 | 631 | syms aXi bXi Xi(aXi, bXi) 632 | Xi(aXi, bXi) = 0; 633 | 634 | for k = 1:8 635 | Xi(aXi, bXi) = Xi(aXi, bXi) + exp(-bXi^2)/2 * a_arr(k)... 636 | * exp((k/(2*aXi) + bXi)^2) * erfc(k/(2*aXi) + bXi); 637 | end 638 | 639 | syms zeta2 nu 640 | EC_LN(zeta2, nu) = ... 641 | Xi(1/sqrt(2*zeta2), nu/sqrt(2*zeta2))... 642 | + Xi(1/sqrt(2*zeta2), -nu/sqrt(2*zeta2))... 643 | + sqrt(zeta2/2/pi) * exp(-nu^2/(2*zeta2))... 644 | + nu/2*erfc(-nu/sqrt(2*zeta2)); 645 | 646 | for idx = 1:length(SNRdB) 647 | avgSNR = db2pow(SNRdB(idx)); % 10^(SNRdB(idx)/10) 648 | 649 | EC_non_RIS_sim(idx) = mean(log2(1 + avgSNR*SNR_h0)); 650 | 651 | EC_ERA_sim(idx) = mean(log2(1+avgSNR*Z2_ERA)); 652 | 653 | EC_ERA_ana(idx) = double(vpa(EC_LN(zeta2_Z2_ERA_LN, log(avgSNR) + nu_Z2_ERA_LN)))/log(2); 654 | 655 | EC_ORA_sim(idx) = mean(log2(1+avgSNR*R2_ORA)); 656 | 657 | EC_ORA_ana(idx) = double(vpa(EC_LN(zeta2_R2_ORA_LN, log(avgSNR) + nu_R2_ORA_LN)))/log(2); 658 | 659 | fprintf('Ergodic capacity, SNR = % d \n', round(SNRdB(idx))); 660 | end 661 | 662 | figure; 663 | 664 | plot(P_S_dB, EC_non_RIS_sim, 'b+-'); hold on; 665 | plot(P_S_dB, EC_ERA_sim, 'ro:'); hold on; 666 | plot(P_S_dB, EC_ERA_ana, 'r-'); hold on; 667 | plot(P_S_dB, EC_ORA_sim, 'bs:'); hold on; 668 | plot(P_S_dB, EC_ORA_ana, 'b-'); hold on; 669 | 670 | xlabel('$P_{\rm S}$ [dBm]', 'Interpreter', 'Latex'); 671 | ylabel('Ergodic capacity [b/s/Hz]', 'Interpreter', 'Latex'); 672 | legend('Non-RIS (sim.)',... 673 | 'ERA (sim.)',... 674 | 'ERA (ana. with Gamma)',... 675 | 'ORA (sim.)',... 676 | 'ORA (analytical)',... 677 | 'Interpreter', 'Latex',... 678 | 'Location','NW'); 679 | 680 | toc 681 | -------------------------------------------------------------------------------- /main_coChannel_interference_simulation.m: -------------------------------------------------------------------------------- 1 | %% PAPER 2 | 3 | % Title: Multi-RIS-aided Wireless Systems: Statistical Characterization and Performance Analysis 4 | % Authors : Tri Nhu Do, Georges Kaddoum, Thanh Luan Nguyen, Daniel Benevides da Costa, Zygmunt J. Haas 5 | % Online: https://github.com/trinhudo/Multi-RIS 6 | % Version: 12-Sep-2021 7 | 8 | % Multi-cell multi-RIS with detailed phase-shift configuration 9 | % --ERA scheme with inter-cell interference: all RISs participate 10 | % --ORA scheme with inter-cell interference: only the best RIS participates 11 | % --Simulation only 12 | 13 | tic 14 | clear all 15 | close all 16 | 17 | %% SETTING 18 | 19 | sim_times = 1e5; % Number of simulation trails 20 | 21 | R_th = 3; % Predefined target spectral efficiency [b/s/Hz] 22 | SNR_th = 2^R_th-1; % Predefined SNR threshold 23 | 24 | N_RIS = 5; % number of distributed RIS 25 | 26 | L_single = 40; % Number of elements at each RIS 27 | 28 | L = L_single*ones(1,N_RIS); % all RISs 29 | 30 | kappa_nl = 1; % Amplitude reflection coefficient 31 | 32 | % Network area 33 | x_area_min = 0; 34 | x_area_max = 100; % in meters 35 | y_area_min = 0; 36 | y_area_max = 10; 37 | 38 | % Source location, base station 1 (BS1) 39 | x_S1 = x_area_min; 40 | y_S1 = y_area_min; 41 | 42 | % BS2 43 | x_S2 = x_area_min-44; 44 | y_S2 = y_area_min; 45 | 46 | % BS3 47 | x_S3 = x_area_min+177; 48 | y_S3 = y_area_min; 49 | 50 | % Destination location 51 | x_des = x_area_max; 52 | y_des = y_area_min; 53 | 54 | % % Random location setting 55 | % x_RIS = x_area_min + (x_area_max-x_area_min)*rand(N_RIS, 1); % [num_RIS x 1] vector 56 | % y_RIS = y_area_min + (y_area_max-y_area_min)*rand(N_RIS, 1); 57 | 58 | %Location setting D1 59 | x_RIS = [7; 13; 41; 75; 93]; 60 | y_RIS = [2; 6; 8; 4; 3]; 61 | 62 | % Compute location of nodes 63 | pos_S1 = [x_S1, y_S1]; 64 | pos_S2 = [x_S2, y_S2]; 65 | pos_S3 = [x_S3, y_S3]; 66 | 67 | pos_des = [x_des, y_des]; 68 | 69 | pos_RIS = [x_RIS, y_RIS]; % [num_RIS x 2] matrix 70 | 71 | % Compute distances 72 | d_S1R = sqrt(sum((pos_S1 - pos_RIS).^2 , 2)); % [num_RIS x 1] vector 73 | d_S2R = sqrt(sum((pos_S2 - pos_RIS).^2 , 2)); % [num_RIS x 1] vector 74 | d_S3R = sqrt(sum((pos_S3 - pos_RIS).^2 , 2)); % [num_RIS x 1] vector 75 | 76 | d_RD = sqrt(sum((pos_RIS - pos_des).^2 , 2)); 77 | 78 | d_S1D = sqrt(sum((pos_S1 - pos_des).^2 , 2)); 79 | d_S2D = sqrt(sum((pos_S2 - pos_des).^2 , 2)); 80 | d_S3D = sqrt(sum((pos_S3 - pos_des).^2 , 2)); 81 | 82 | %% NETWORK TOPOLOGY 83 | 84 | figure; 85 | 86 | scatter(x_S1, y_S1, 100, 'b^', 'filled'); hold on 87 | scatter(x_des, y_des, 100, 'go', 'filled'); hold on 88 | scatter(x_RIS, y_RIS, 100, 'rs', 'filled'); hold on 89 | scatter(x_S2, y_S2, 100, 'b^', 'filled'); hold on 90 | scatter(x_S3, y_S3, 100, 'b^', 'filled'); hold on 91 | 92 | text(x_S1+3, y_S1+.5, 'BS_0') 93 | text(x_S2+3, y_S2+.5, 'BS_1') 94 | text(x_S3+3, y_S3+.5, 'BS_2') 95 | 96 | for kk = 1:N_RIS 97 | text(x_RIS(kk)+5, y_RIS(kk), num2str(kk)); 98 | hold on 99 | end 100 | 101 | xlabel('$d_{\rm SD}$ (m)', 'Interpreter', 'Latex') 102 | ylabel('$H$ (m)', 'Interpreter', 'Latex') 103 | legend('$\mathrm{BS}_m$', '$\rm D$', '$\mathrm{RIS}_n$',... 104 | 'Interpreter', 'Latex',... 105 | 'Location', 'best') 106 | 107 | % set(gca, 'LooseInset', get(gca, 'TightInset')) % remove plot padding 108 | set(gca,'fontsize',13); 109 | hold off 110 | 111 | % Path-loss model 112 | % --------------- 113 | 114 | % Carrier frequency (in GHz) 115 | fc = 3; % GHz 116 | 117 | % 3GPP Urban Micro in 3GPP TS 36.814, Mar. 2010. 118 | % Note that x is measured in meter 119 | 120 | % NLoS path-loss component based on distance 121 | pathloss_NLOS = @(x) db2pow(-22.7 - 26*log10(fc) - 36.7*log10(x)); 122 | 123 | antenna_gain_S = db2pow(5); % Source antenna gain, dBi 124 | antenna_gain_RIS = db2pow(5); % Gain of each element of a RIS, dBi 125 | antenna_gain_D = db2pow(0); % Destination antenna gain, dBi 126 | 127 | % Noise power and Transmit power P_S 128 | % ---------------------------------- 129 | 130 | BW = 10e6; % Bandwidth : 10 MHz 131 | 132 | noiseFiguredB = 10; % Noise figure (in dB) 133 | 134 | % Compute the noise power in dBm 135 | sigma2dBm = -174 + 10*log10(BW) + noiseFiguredB; % -94 dBm 136 | sigma2 = db2pow(sigma2dBm); 137 | 138 | P_S_dB = -5:.1:25; % Transmit power of the source, dBm, e.g., 200mW = 23dBm 139 | 140 | SNRdB = P_S_dB - sigma2dBm; % Average transmit SNR, dB = dBm - dBm, bar{rho} = P_S / sigma2 141 | 142 | %% CO-CHANNEL INTER-CELL INTERFERENCE | CHANNEL MODELING 143 | 144 | % Nakagami scale parameter 145 | m_0_S1 = 2.5 + rand; % S->D, scale parameter, heuristic setting 146 | m_0_S2 = 2.5 + rand; 147 | m_0_S3 = 2.5 + rand; 148 | 149 | m_h_S1 = 2.5 + rand(N_RIS, 1); % S->R 150 | m_h_S2 = 2.5 + rand(N_RIS, 1); 151 | m_h_S3 = 2.5 + rand(N_RIS, 1); 152 | 153 | m_g = 2.5 + rand(N_RIS, 1); % R->D, for all sources 154 | 155 | % Nakagami spread parameter 156 | % can be used for all sources 157 | Omega_0 = 1; % Normalized spread parameter of S->D link 158 | Omega_h = 1; % Normalized spread parameter of S->RIS link 159 | Omega_g = 1; % Normalized spread parameter of RIS->D link 160 | 161 | % Path-loss 162 | path_loss_0_S1 = pathloss_NLOS(d_S1D)*antenna_gain_S; % S->D link 163 | path_loss_0_S2 = pathloss_NLOS(d_S2D)*antenna_gain_S; 164 | path_loss_0_S3 = pathloss_NLOS(d_S3D)*antenna_gain_S; 165 | 166 | path_loss_h_S1 = pathloss_NLOS(d_S1R) * antenna_gain_S*antenna_gain_RIS*L_single; % Source -> RIS 167 | path_loss_h_S2 = pathloss_NLOS(d_S2R) * antenna_gain_S*antenna_gain_RIS*L_single; 168 | path_loss_h_S3 = pathloss_NLOS(d_S3R) * antenna_gain_S*antenna_gain_RIS*L_single; 169 | 170 | path_loss_g = pathloss_NLOS(d_RD) * antenna_gain_RIS*L_single*antenna_gain_D; % RIS -> Des 171 | 172 | % phase of channels 173 | phase_h_S1D = 2*pi*rand(1, sim_times); % domain [0,2pi) 174 | phase_h_S2D = 2*pi*rand(1, sim_times); 175 | phase_h_S3D = 2*pi*rand(1, sim_times); 176 | 177 | phase_h_S1R = 2*pi*rand(N_RIS, L_single, sim_times); % domain [0,2pi) 178 | phase_h_S2R = 2*pi*rand(N_RIS, L_single, sim_times); 179 | phase_h_S3R = 2*pi*rand(N_RIS, L_single, sim_times); 180 | 181 | phase_g_RD = 2*pi*rand(N_RIS, L_single, sim_times); % domain [0,2pi) 182 | 183 | phase_h_S1R_eachRIS = zeros(L_single, sim_times); 184 | phase_h_S2R_eachRIS = zeros(L_single, sim_times); 185 | phase_h_S3R_eachRIS = zeros(L_single, sim_times); 186 | 187 | phase_g_RD_eachRIS = zeros(L_single, sim_times); 188 | 189 | % Channel modeling 190 | 191 | h_S1D = sqrt(path_loss_0_S1) * random('Naka', m_0_S1, Omega_0, [1, sim_times]) .* exp(1i*phase_h_S1D); 192 | h_S2D = sqrt(path_loss_0_S2) * random('Naka', m_0_S2, Omega_0, [1, sim_times]) .* exp(1i*phase_h_S2D); 193 | h_S3D = sqrt(path_loss_0_S3) * random('Naka', m_0_S3, Omega_0, [1, sim_times]) .* exp(1i*phase_h_S3D); 194 | 195 | h_S1R = zeros(N_RIS,L_single,sim_times); 196 | h_S2R = zeros(N_RIS,L_single,sim_times); 197 | h_S3R = zeros(N_RIS,L_single,sim_times); 198 | 199 | g_RD = zeros(N_RIS,L_single,sim_times); 200 | 201 | for nn=1:N_RIS 202 | phase_h_S1R_eachRIS = squeeze(phase_h_S1R(nn,:,:)); % random() just uses 2D 203 | phase_h_S2R_eachRIS = squeeze(phase_h_S2R(nn,:,:)); 204 | phase_h_S3R_eachRIS = squeeze(phase_h_S3R(nn,:,:)); 205 | 206 | phase_g_RD_eachRIS = squeeze(phase_g_RD(nn,:,:)); % random() just uses 2D 207 | 208 | for kk=1:L(nn) 209 | h_S1R(nn,kk,:) = sqrt(path_loss_h_S1(nn)) .* ... % need sqrt because path-loss is outside of random() 210 | random('Naka', m_h_S1(nn), Omega_h, [1, sim_times]) .* ... 211 | exp(1i*phase_h_S1R_eachRIS(kk,:)); 212 | 213 | h_S2R(nn,kk,:) = sqrt(path_loss_h_S2(nn)) .* ... 214 | random('Naka', m_h_S2(nn), Omega_h, [1, sim_times]) .* ... 215 | exp(1i*phase_h_S2R_eachRIS(kk,:)); 216 | 217 | h_S3R(nn,kk,:) = sqrt(path_loss_h_S3(nn)) .* ... 218 | random('Naka', m_h_S3(nn), Omega_h, [1, sim_times]) .* ... 219 | exp(1i*phase_h_S3R_eachRIS(kk,:)); 220 | 221 | g_RD(nn,kk,:) = sqrt(path_loss_g(nn)) .* ... % need sqrt because path-loss is outside of random() 222 | random('Naka', m_g(nn), Omega_g, [1, sim_times]) .* ... 223 | exp(1i*phase_g_RD_eachRIS(kk,:)); 224 | end 225 | end 226 | 227 | %% CO-CHANNEL INTER-CELL INTERFERENCE | ERA SCHEME 228 | % Phase-shift configuration based on channels of S1 229 | 230 | h_ERA_cascade_S1 = zeros(N_RIS, sim_times); 231 | h_ERA_cascade_S2 = zeros(N_RIS, sim_times); 232 | h_ERA_cascade_S3 = zeros(N_RIS, sim_times); 233 | 234 | for ss = 1:sim_times % loop over simulation trials 235 | for nn=1:N_RIS % loop over each RIS 236 | phase_shift_config_ideal = zeros(L_single,1); 237 | phase_shift_config_ideal_normalized = zeros(L_single,1); 238 | phase_shift_complex_vector = zeros(L_single,1); 239 | for ll = 1:L_single % loop over each elements of one RIS 240 | % unknown domain phase-shift 241 | phase_shift_config_ideal(ll) = phase_h_S1D(ss) - phase_h_S1R(nn,ll,ss) - phase_g_RD(nn,ll,ss); 242 | % convert to domain of [0, 2pi) 243 | phase_shift_config_ideal_normalized(ll) = wrapTo2Pi(phase_shift_config_ideal(ll)); 244 | phase_shift_complex_vector(ll) = exp(1i*phase_shift_config_ideal_normalized(ll)); 245 | end 246 | 247 | phase_shift_matrix = kappa_nl .* diag(phase_shift_complex_vector); % diagonal matrix 248 | 249 | % Cascade channel (complex, not magnitude) 250 | h_ERA_cascade_S1(nn,ss) = h_S1R(nn,:,ss) * phase_shift_matrix * g_RD(nn,:,ss).'; 251 | h_ERA_cascade_S2(nn,ss) = h_S2R(nn,:,ss) * phase_shift_matrix * g_RD(nn,:,ss).'; 252 | h_ERA_cascade_S3(nn,ss) = h_S3R(nn,:,ss) * phase_shift_matrix * g_RD(nn,:,ss).'; 253 | end 254 | end 255 | 256 | h_ERA_e2e_magnitude_S1 = abs(h_S1D + sum(h_ERA_cascade_S1,1)); % Magnitude of e2e channel 257 | h_ERA_e2e_magnitude_S2 = abs(h_S2D + sum(h_ERA_cascade_S2,1)); 258 | h_ERA_e2e_magnitude_S3 = abs(h_S3D + sum(h_ERA_cascade_S3,1)); 259 | 260 | Z2_ERA = h_ERA_e2e_magnitude_S1.^2; 261 | 262 | % Components of SINR 263 | 264 | S_ERA = h_ERA_e2e_magnitude_S1.^2; 265 | I_ERA = h_ERA_e2e_magnitude_S2.^2 + h_ERA_e2e_magnitude_S3.^2; 266 | W = 1; 267 | 268 | %% CO-CHANNEL INTER-CELL INTERFERENCE | ORA SCHEME 269 | 270 | h_ORA_cascade_S1 = zeros(1,sim_times); 271 | h_ORA_cascade_S2 = zeros(1,sim_times); 272 | h_ORA_cascade_S3 = zeros(1,sim_times); 273 | 274 | [~,idx] = max(h_ERA_cascade_S1,[],1); % find the best RIS associated with BS1 275 | 276 | for ss = 1:sim_times 277 | phase_shift_config_ideal = zeros(L_single,1); 278 | phase_shift_config_ideal_normalized = zeros(L_single,1); 279 | phase_shift_complex_vector = zeros(L_single,1); 280 | for ll = 1:L_single % loop over each elements of one RIS 281 | % unknown domain phase-shift 282 | phase_shift_config_ideal(ll) = phase_h_S1D(ss) - phase_h_S1R(idx(ss),ll,ss) - phase_g_RD(idx(ss),ll,ss); 283 | % convert to domain of [0, 2pi) 284 | phase_shift_config_ideal_normalized(ll) = wrapTo2Pi(phase_shift_config_ideal(ll)); 285 | phase_shift_complex_vector(ll) = exp(1i*phase_shift_config_ideal_normalized(ll)); 286 | end 287 | 288 | phase_shift_matrix = kappa_nl .* diag(phase_shift_complex_vector); 289 | 290 | % cascade channel (complex number, not magnitude) 291 | h_ERA_cascade_S1(idx(ss),ss) = h_S1R(idx(ss),:,ss) * phase_shift_matrix * g_RD(idx(ss),:,ss).'; % returns a single number 292 | h_ERA_cascade_S2(idx(ss),ss) = h_S2R(idx(ss),:,ss) * phase_shift_matrix * g_RD(idx(ss),:,ss).'; 293 | h_ERA_cascade_S3(idx(ss),ss) = h_S3R(idx(ss),:,ss) * phase_shift_matrix * g_RD(idx(ss),:,ss).'; 294 | 295 | h_ORA_cascade_S1(ss) = h_ERA_cascade_S1(idx(ss),ss); 296 | h_ORA_cascade_S2(ss) = h_ERA_cascade_S2(idx(ss),ss); 297 | h_ORA_cascade_S3(ss) = h_ERA_cascade_S3(idx(ss),ss); 298 | end 299 | 300 | h_ORA_e2e_magnitude_S1 = abs(h_S1D + h_ORA_cascade_S1); 301 | h_ORA_e2e_magnitude_S2 = abs(h_S2D + h_ORA_cascade_S2); 302 | h_ORA_e2e_magnitude_S3 = abs(h_S3D + h_ORA_cascade_S3); 303 | 304 | R2_ORA = h_ORA_e2e_magnitude_S1.^2; 305 | 306 | S_ORA = h_ORA_e2e_magnitude_S1.^2; 307 | I_ORA = h_ORA_e2e_magnitude_S2.^2 + h_ORA_e2e_magnitude_S3.^2; 308 | 309 | %% OUTAGE PROBABILITY 310 | 311 | SNR_h0 = abs(h_S1D).^2; 312 | 313 | for rr = 1:length(SNRdB) 314 | avgSNR = db2pow(SNRdB(rr)); % i.e., 10^(SNRdB/10) 315 | 316 | OP_SISO(rr) = mean(avgSNR*SNR_h0 < SNR_th); 317 | 318 | OP_ERA_no_interference_sim(rr) = mean(avgSNR.*Z2_ERA < SNR_th); 319 | OP_ERA_interference_sim(rr) = mean(avgSNR*S_ERA./(avgSNR*I_ERA+1) < SNR_th); 320 | 321 | OP_ORA_no_interference_sim(rr) = mean(avgSNR.*R2_ORA < SNR_th); 322 | OP_ORA_interference_sim(rr) = mean(avgSNR*S_ORA./(avgSNR*I_ORA+1) < SNR_th); 323 | 324 | % fprintf('Outage probability, SNR = % d \n', round(SNRdB(rr))); 325 | end 326 | 327 | figure; 328 | semilogy(P_S_dB, OP_SISO, 'k-', 'linewidth', 2); hold on; 329 | semilogy(P_S_dB, OP_ERA_no_interference_sim, 'r-', 'linewidth', 2); hold on; 330 | semilogy(P_S_dB, OP_ERA_interference_sim, 'r--', 'linewidth', 2); hold on; 331 | semilogy(P_S_dB, OP_ORA_no_interference_sim, 'b-', 'linewidth', 2); hold on; 332 | semilogy(P_S_dB, OP_ORA_interference_sim, 'b--', 'linewidth', 2); hold on; 333 | 334 | xlabel('$P_{\rm S}$ [dBm]', 'Interpreter', 'Latex'); 335 | ylabel('Outage probability, $P_{\rm out}$', 'Interpreter', 'Latex'); 336 | legend('Non-RIS (sim.)',... 337 | 'ERA (sim., no interference)', ... 338 | 'ERA (sim., w/ interference)', ... 339 | 'ORA (sim., no interference)', ... 340 | 'ORA (sim., w/ interference)', ... 341 | 'Location','SW',... 342 | 'Interpreter', 'Latex'); 343 | axis([-Inf Inf 10^(-4) 10^(0)]); 344 | 345 | %% ERGODIC CAPACITY 346 | 347 | for rr = 1:length(SNRdB) 348 | avgSNR = db2pow(SNRdB(rr)); % 10^(SNRdB(idx)/10) 349 | 350 | EC_non_RIS(rr) = mean(log2(1 + avgSNR*SNR_h0)); 351 | 352 | EC_ERA_no_interference_sim(rr) = mean(log2(1+avgSNR*Z2_ERA)); 353 | EC_ERA_interference_sim(rr) = mean(log2(1 + avgSNR*S_ERA./(avgSNR*I_ERA+1) )); 354 | 355 | EC_ORA_no_interference_sim(rr) = mean(log2(1+avgSNR*R2_ORA)); 356 | EC_ORA_interference_sim(rr) = mean(log2(1 + avgSNR*S_ORA./(avgSNR*I_ORA+1) )); 357 | 358 | % fprintf('Ergodic capacity, SNR = % d \n', round(SNRdB(rr))); 359 | end 360 | 361 | figure; 362 | plot(P_S_dB, EC_non_RIS, 'k-', 'linewidth', 2); hold on; 363 | plot(P_S_dB, EC_ERA_no_interference_sim, 'r-', 'linewidth', 2); hold on; 364 | plot(P_S_dB, EC_ERA_interference_sim, 'r--', 'linewidth', 2); hold on; 365 | plot(P_S_dB, EC_ORA_no_interference_sim, 'b-', 'linewidth', 2); hold on; 366 | plot(P_S_dB, EC_ORA_interference_sim, 'b--', 'linewidth', 2); hold on; 367 | 368 | 369 | xlabel('$P_{\rm S}$ [dBm]', 'Interpreter', 'Latex'); 370 | ylabel('Ergodic capacity [b/s/Hz]', 'Interpreter', 'Latex'); 371 | legend('Non-RIS (sim.)',... 372 | 'ERA (sim., no interference)', ... 373 | 'ERA (sim., w/ interference)', ... 374 | 'ORA (sim., no interference)', ... 375 | 'ORA (sim., w/ interference)', ... 376 | 'Interpreter', 'Latex',... 377 | 'Location','NW'); 378 | 379 | % save('data_Gamma_setL2_interference.mat',... 380 | % 'OP_ERA_no_interference_sim',... 381 | % 'OP_ERA_interference_sim',... 382 | % 'OP_ORA_no_interference_sim',... 383 | % 'OP_ORA_interference_sim',... 384 | % 'EC_ERA_no_interference_sim',... 385 | % 'EC_ERA_interference_sim',... 386 | % 'EC_ORA_no_interference_sim',... 387 | % 'EC_ORA_interference_sim') 388 | toc -------------------------------------------------------------------------------- /main_energy_efficiency.m: -------------------------------------------------------------------------------- 1 | %% Paper 2 | 3 | % Title: Multi-RIS-aided Wireless Systems: Statistical Characterization and Performance Analysis 4 | % Authors : Tri Nhu Do, Georges Kaddoum, Thanh Luan Nguyen, Daniel Benevides da Costa, Zygmunt J. Haas 5 | % Online: https://github.com/trinhudo/Multi-RIS 6 | % Version: 12-Sep-2021 7 | 8 | % Energy efficiency of ERA and ORA scheme 9 | 10 | %% Setting 11 | 12 | clear all 13 | close all 14 | 15 | sim_trials = 1e5; % Number of simulation trails 16 | 17 | N_RIS = 5; % Number of RISs 18 | 19 | L = 25*ones(1, N_RIS); % Element setting L1 20 | 21 | kappa_nl = 1; % Amplitude reflection coefficient 22 | 23 | % Nakagami m parameter 24 | m_0 = 2.5 + rand; % Scale parameter, Heuristic setting 25 | m_h = 2.5 + rand(N_RIS, 1); 26 | m_g = 2.5 + rand(N_RIS, 1); 27 | 28 | % Network area 29 | % ------------ 30 | 31 | x_area_min = 0; 32 | x_area_max = 100; 33 | y_area_min = 0; 34 | y_area_max = 10; 35 | 36 | % Source location 37 | x_source = x_area_min; 38 | y_source = y_area_min; 39 | 40 | % Destination location 41 | x_des = x_area_max; 42 | y_des = y_area_min; 43 | 44 | % Random topology 45 | x_RIS = x_area_min + (x_area_max-x_area_min)*rand(N_RIS, 1); % [num_RIS x 1] vector 46 | y_RIS = y_area_min + (y_area_max-y_area_min)*rand(N_RIS, 1); 47 | 48 | % Compute location of nodes 49 | pos_source = [x_source, y_source]; 50 | pos_des = [x_des, y_des]; 51 | pos_RIS = [x_RIS, y_RIS]; % [num_RIS x 2] matrix 52 | 53 | % Compute distances 54 | d_sr = sqrt(sum((pos_source - pos_RIS).^2 , 2)); % [num_RIS x 1] vector 55 | d_rd = sqrt(sum((pos_RIS - pos_des).^2 , 2)); 56 | d_sd = sqrt(sum((pos_source - pos_des).^2 , 2)); 57 | 58 | % Path-loss model 59 | % --------------- 60 | 61 | % Carrier frequency (in GHz) 62 | fc = 3; % GHz 63 | 64 | % 3GPP Urban Micro in 3GPP TS 36.814 65 | pathloss_NLOS = @(x) db2pow(-22.7 - 26*log10(fc) - 36.7*log10(x)); 66 | 67 | antenna_gain_S = db2pow(5); % Source antenna gain, dBi 68 | antenna_gain_RIS = db2pow(5); % Gain of each element of a RIS, dBi 69 | antenna_gain_D = db2pow(0); % Destination antenna gain, dBi 70 | 71 | % Noise power and Transmit power P_S 72 | % ---------------------------------- 73 | 74 | % Bandwidth 75 | BW = 10e6; % 10 MHz 76 | 77 | % Noise figure (in dB) 78 | noiseFiguredB = 10; 79 | 80 | % Compute the noise power in dBm 81 | sigma2dBm = -174 + 10*log10(BW) + noiseFiguredB; % -94 dBm 82 | sigma2 = db2pow(sigma2dBm); 83 | 84 | P_S_dB = -30:.1:50; % Transmit power of the source, dBm, e.g., 200mW = 23dBm 85 | 86 | SNR_dB = P_S_dB - sigma2dBm; % Average transmit SNR, dB = dBm - dBm 87 | 88 | %% Simplified Simulation 89 | 90 | % Direct channel h_0 91 | Omg_0 = pathloss_NLOS(d_sd)*antenna_gain_S; % Omega of S->D link 92 | 93 | h_0 = random('Naka', m_0, Omg_0, [1, sim_trials]); 94 | SNR_h0 = abs(h_0).^2; 95 | 96 | V_n = zeros(N_RIS, sim_trials); 97 | Omg_h = zeros(N_RIS, 1); 98 | Omg_g = zeros(N_RIS, 1); 99 | 100 | for nn = 1:N_RIS 101 | for kk = 1:L(nn) 102 | Omg_h(nn) = pathloss_NLOS(d_sr(nn))*antenna_gain_S*antenna_gain_RIS*L(nn); % Omega S->R 103 | Omg_g(nn) = pathloss_NLOS(d_rd(nn))*antenna_gain_RIS*L(nn)*antenna_gain_D; % Omega R->D 104 | 105 | h_nl = random('Naka', m_h(nn), Omg_h(nn), [1, sim_trials]); 106 | g_nl = random('Naka', m_g(nn), Omg_g(nn), [1, sim_trials]); 107 | 108 | U_nl = kappa_nl * h_nl .* g_nl; 109 | 110 | V_n(nn, :) = V_n(nn, :) + U_nl; 111 | end 112 | end 113 | 114 | % ERA scheme 115 | 116 | T_ERA = sum(V_n, 1); 117 | Z_ERA = h_0 + T_ERA; % Magnitude of the e2e channel 118 | Z2_ERA = Z_ERA.^2; % Squared magnitude of the e2e channel 119 | 120 | % ORA scheme 121 | 122 | [V_M_ORA, id_RIS] = max(V_n, [], 1); % V_M for the best RIS 123 | R_ORA = h_0 + V_M_ORA; % Magnitude of the e2e channel 124 | R2_ORA = R_ORA.^2; % Squared magnitude of the e2e channel 125 | 126 | % Performance metrics 127 | 128 | for isnr = 1:length(SNR_dB) 129 | % fprintf('EC, SNR = % d \n', SNR_dB(isnr)); 130 | snr = 10^(SNR_dB(isnr)/10); 131 | 132 | EC_ERA_sim(isnr) = mean(log2(1+snr*Z2_ERA)); 133 | EC_ORA_sim(isnr) = mean(log2(1+snr*R2_ORA)); 134 | 135 | end 136 | 137 | %% Numerical Results 138 | 139 | % Transmit Power 140 | % -------------- 141 | 142 | EC = 1:.5:20; 143 | P_tx_ERA = zeros(1, length(EC)); 144 | P_tx_ORA = zeros(1, length(EC)); 145 | 146 | for ii = 1:length(EC) 147 | idx = find(EC_ERA_sim <= EC(ii)); 148 | P_tx_ERA(ii) = db2pow(P_S_dB(idx(end))); % 10^(SNR_dB(idx(end))/10); 149 | idx = find(EC_ORA_sim <= EC(ii)); 150 | P_tx_ORA(ii) = db2pow(P_S_dB(idx(end))); % 10^(SNR_dB(idx(end))/10); 151 | end 152 | 153 | figure; 154 | 155 | plot(EC, P_tx_ERA, 'r-', 'linewidth', 2); hold on 156 | plot(EC, P_tx_ORA, 'b-', 'linewidth', 2); hold on 157 | 158 | xlabel('Achievable rate [b/s/Hz]') 159 | ylabel('Transmit power [mW]') 160 | legend('ERA scheme', 'ORA scheme', 'location', 'best') 161 | 162 | % Engery Efficiency 163 | % ----------------- 164 | 165 | P_c_S = db2pow(10); % Circuit dissipated power at S = 10 dBm 166 | P_c_D = db2pow(10); % Circuit dissipated power at S = 10 dBm 167 | P_c_element = 7.8; % mW 168 | 169 | for kk=1:length(EC) 170 | P_total_ERA(kk) = P_tx_ERA(kk) + sum(L)*P_c_element + P_c_S + P_c_D; 171 | P_total_ORA(kk) = P_tx_ORA(kk) + max(L)*P_c_element + P_c_S + P_c_D; 172 | end 173 | 174 | EE_ERA = BW*EC./P_total_ERA/1e3; 175 | EE_ORA = BW*EC./P_total_ORA/1e3; 176 | 177 | figure; 178 | 179 | plot(EC, EE_ERA, 'r-', 'linewidth', 2); hold on 180 | plot(EC, EE_ORA, 'b-', 'linewidth', 2); hold on 181 | xlabel('Average achievable rate [b/s/Hz]') 182 | ylabel('Energy efficiency [Mbit/Joule]') 183 | legend('ERA scheme', 'ORA scheme', ... 184 | 'location', 'best') 185 | -------------------------------------------------------------------------------- /nsumk.m: -------------------------------------------------------------------------------- 1 | function [m,x] = nsumk(n,k) 2 | % NSUMK Number and listing of non-negative integer n-tuples summing to k 3 | % M = NSUMK(N,K) where N and K are positive integers returns M=nchoosek(K+N-1,N-1) 4 | % This is the number of ordered N-tuples of non-negative integers summing to K 5 | % 6 | % [M,X] = NSUMK(N,K) produces a matrix X with 7 | % nchoosek(K+N-1,N-1) rows and n columns. Each row comprises 8 | % non-negative integers summing to k. The ordering of rows follows the 9 | % same convention as NCHOOSEK, which is undocumented but with some 10 | % reliability appears to be lexicographic. The reverse of this presumed ordering 11 | % is a natural way to list coefficients of polynomials in N variables of degree K. 12 | % As per nchoosek, this syntax is only practical for situations where N is 13 | % less than about 15. 14 | % 15 | % EXAMPLES: m = nsumk(5,2) 16 | % [~,x] = nsumk(5,2) returns a 15 x 5 matrix x in which rows sum to 2 17 | 18 | % Peter Cotton (2021). nsumk (https://www.mathworks.com/matlabcentral/fileexchange/28340-nsumk), MATLAB Central File Exchange. 19 | 20 | if isscalar(n) && isscalar(k) && nargout<=1 21 | m = nchoosek(k+n-1,n-1); 22 | elseif isscalar(n) && isscalar(k) && nargout==2 23 | m = nchoosek(k+n-1,n-1); 24 | dividers = [zeros(m,1),nchoosek((1:(k+n-1))',n-1),ones(m,1)*(k+n)]; 25 | x = diff(dividers,1,2)-1; 26 | else 27 | error('nsumk anticipates scalar k and n'); 28 | end 29 | --------------------------------------------------------------------------------