In this paper, we discuss the computational method for allocating sensing nodes for sensor networks or base stations for cellular networks in inhomogeneous propagation environments. First, we consider the 1-ray model combined with the 2-ray model using the amplitude modification factor alpha and the propagation order of distance beta as well as the field matching factor gamma. Second, we introduce an expression to compute communication distance. Third, we apply PSO to optimally allocate sensor nodes or base stations by use of the communication distance function derived from the communication distance. In numerical examples, we show an adaptive algorithm for generating inhomogeneous triangular cells to achieve optimal allocations of base stations.