I was wondering how does Boeing and Airbus decide what range for each aircraft will be doing? What I mean is when Airbus and Boeing decide to make newer airplane the A380, A340-500, B787s, B777s and so on, how do they decide what range for each aircraft will do? what kind of math solving problem do they use? You have to consider the weight of the aircraft, speed,
amount of fuel onboard plus passengers and luggage and or cargo and type of engine will be using. For instance 787s-8 Boeing decide the range for that a/c will be 8000 to 8500 miles while the 78-9s will do 8600 to 8800 miles or approx, sorry can't remember the exact range for each aircraft. We all know before the production, the 787s is on drawing board.

It's a huge field of study -- aircraft sizing. Done right, it requires combining engineering and economics. If you want the airplane to fly a bit further, how much more can you charge for each one and how many more can you sell, but how much does that increase the operating cost on shorter flights and thus reduce the number you will sell or how much you can charge for them, and what, if any, impact is there on production and/or development costs and risk.

Some thoughts on your actual questions:

Yes you do need to consider the empty weight of the aircraft and its aerodynamic characteristics and its engines (which may be tailor-designed for the airplane and thus available in exactly the right thrust -- too big adds extra weight and drag, too small not enough capability -- but that may also add cost, so you might want to stick to existing engines which limits your choices... you get the picture!). Keep in mind that the empty weight of the aircraft is a function of the structural requirements which is a function of the weight of the aircraft, so it's iterative/implicit. Historical winds and temperatures enter in as well. The size and shape of the airplane and its design payload and engines and speed produce a range, and you can vary whichever of the above to get the result you want, while also meeting operational and regulatory constraints like field performance and structural integrity. You also want good economic performance on shorter missions, lower payload missions, etc., so multiple design "modes" should be considered. Historically a lot of that was done using parametric studies, but multidisciplinary design optimization has gotten involved; maybe someone from one of the airframe manufacturers can tell us exactly how much of a role MDO plays now.

Some aircraft sales are in fact driven by a single city-pair, so one might reasonably conclude that airplane design can be driven by certain target range/payload combinations also (again, more than just one -- different modes).

Recent research is also attempting to demonstrate how a manufacturer should be simlutaneously designing a family of aircraft, where each might not be the optimal design on its own but together they are an optimal solution -- this brings economics in more explicitly.

I know that was wordy and not very precise, hope it helps. If you want I can dig up some references.