This paper addresses topology optimization problem for an ultra wide band (UWB) localization network, where trilateration is used to obtain the target position based on its distances from fixed and known anchors. Our goal is to minimize the number of anchors needed to localize a target, while keeping the localization uncertainty lower than a given threshold in an area of arbitrary shape with obstacles. Our propagation model accounts for the presence of line of sight (LOS) between nodes, while geometric dilution of precision (GDoP) is used to express the localization error introduced by trilateration. We propose two integer linear programming formulations to solve the problem. To handle the problems of large sizes, we use the greedy placement with pruning heuristic. We test our solutions through simulation and show that the integer linear programming is appropriate to handle reasonably sized problems, and the heuristic achieves the results, in terms of the number of anchors placed, within lessthan 2\% of optimum on average.