MATH QUESTION

Talk about general things concerning Forged Alliance Forever.

Moderators: FtXCommando, Ze Dogfather

MATH QUESTION

Postby randall172 » 19 Jun 2019, 01:34

ASSUMING

infinite mass, and infinite build power and +20/s energy to begin with:

what is the fastest build order to achieve +30k power/s?

note: you must also account for energy capacity, and may choose any faction.
randall172
Crusader
 
Posts: 27
Joined: 06 May 2019, 18:30
Has liked: 4 times
Been liked: 0 time
FAF User Name: ExpropriatorNoCompen

Re: MATH QUESTION

Postby Evan_ » 19 Jun 2019, 05:11

Well with infinite buildpower you reclaim stuff so fast that grabbing a 15 energy tree happens instantaneously, giving you 999999 power/s for about 0.0001 seconds. So technically the fastest build order gives you what you want in under a second.

More seriously though, with infinite buildpower, mass, and no enemies attacking you, it depends on the map. If there's a hydro, you start with factory first, since engie + fac + hydro gives 100 power cheaper than 5 pgens (3160 vs 3500) and you'll need a factory later anyways since t2 and t3 on fac cost less e than acu. If not then just spam pgens first. Get enough power, I'd say around 500 since there's a fair gap with hq upgrade and T2 pgen where e won't increase. then upgrade your HQ.

T2 Pgens are way more efficient in both mass and e cost than t1 pgens, but the change in e price between t2 and t3 is not much different (5 t2 pgens cost 60000 e while 1 t3 pgen costs 57600), so you could honestly stay on t2 pgens for the rest of the build if you were just looking to scale up to 30000 and had enough space. After 59 t2 pgens You'd have 30k e. Not at faf computer so couldn't go sandbox it, but it'd probably be around 12 minutes. Incidentally here's probably around the fastest time of 27 minutes if you were playing a "real" game: https://www.youtube.com/watch?v=VBIBZ5otqgg
User avatar
Evan_
Avatar-of-War
 
Posts: 218
Joined: 27 Feb 2016, 18:51
Has liked: 65 times
Been liked: 80 times
FAF User Name: Evan_

Re: MATH QUESTION

Postby Blackheart » 19 Jun 2019, 14:01

Assumptions:

- Infinite mass
- Infinite buildpower in the sense that all power structures are built instantly
- No space issues or walking time
- No tech upgrades required (can be added, shouldnt do more than delay t2 pgen a little)

Observations:
1) Only t1,t2,t3 pgens need to be considered. RAS gives less power than t3 pgen and costs more power than a t3 pgen, hence is dominated strictly under infinite mass and can be eliminated. Same goes for SCU ras. No other e income exists, so we are left with the pgens.
2) If you decide to ever build higher tier, you wont ever build lower tech pgens afterwards (this is assuming open ended income cap, but holds true in this case for almost the entire time. I didnt consider the small margin close to the 30k mark where you might want to make a few t1 pgens to go from 29900-30k for example).
3) It is strictly necessary to build at least t2 pgens, since a full t1 approach can be beaten using higher tech (t1 pgen only takes 295,87 sec, a time that can easily be beaten)
4) A fastest t2 pgen time (achieved with 14,489 t1 pgens taking 161,91 sec, or with 14 /15 t1 pgen taking 161,93 sec respectively, attained by minimizing 75/2 *(16/(1+n) + H_n) where n is the number of t1 pgens and H_n is the n-th harmonic number) does not yield the fastest 30k income time, neither does a payback-time based approach (proven heuristically).
5) Storage is irrelevant, since we will be stalling the entire time. I assumed 0 starting storage.

Since the problem didnt yield to the obvious described methods, i decided to stop thinking and be lazy and code a brute-force approach using the no-return-to-lower-tech assumption. This resulted in 25 t1 pgens, 49 t2 pgens, 2 t3 pgens yielding 30020 power income and taking 253,479 seconds. Note that those pgen numbers stay consistent if you increase the power requirement, so reaching >60k power income just adds t3 pgens to those numbers (60k taking 269,93 seconds).

Im relatively sure that this is very close to the optimal time, the only way i see to improve it would maybe be moving an earlier t1 pgen to the back of the buildorder, but that would, if it gains any time, amount to an extremely small difference. If anyone has better ideas, tell me!
User avatar
Blackheart
Priest
 
Posts: 376
Joined: 04 Jul 2012, 13:26
Has liked: 294 times
Been liked: 299 times
FAF User Name: various

Re: MATH QUESTION

Postby randall172 » 20 Jun 2019, 02:49

Blackheart wrote:Assumptions:

- Infinite mass
- Infinite buildpower in the sense that all power structures are built instantly
- No space issues or walking time
- No tech upgrades required (can be added, shouldnt do more than delay t2 pgen a little)

Observations:
1) Only t1,t2,t3 pgens need to be considered. RAS gives less power than t3 pgen and costs more power than a t3 pgen, hence is dominated strictly under infinite mass and can be eliminated. Same goes for SCU ras. No other e income exists, so we are left with the pgens.
2) If you decide to ever build higher tier, you wont ever build lower tech pgens afterwards (this is assuming open ended income cap, but holds true in this case for almost the entire time. I didnt consider the small margin close to the 30k mark where you might want to make a few t1 pgens to go from 29900-30k for example).
3) It is strictly necessary to build at least t2 pgens, since a full t1 approach can be beaten using higher tech (t1 pgen only takes 295,87 sec, a time that can easily be beaten)
4) A fastest t2 pgen time (achieved with 14,489 t1 pgens taking 161,91 sec, or with 14 /15 t1 pgen taking 161,93 sec respectively, attained by minimizing 75/2 *(16/(1+n) + H_n) where n is the number of t1 pgens and H_n is the n-th harmonic number) does not yield the fastest 30k income time, neither does a payback-time based approach (proven heuristically).
5) Storage is irrelevant, since we will be stalling the entire time. I assumed 0 starting storage.

Since the problem didnt yield to the obvious described methods, i decided to stop thinking and be lazy and code a brute-force approach using the no-return-to-lower-tech assumption. This resulted in 25 t1 pgens, 49 t2 pgens, 2 t3 pgens yielding 30020 power income and taking 253,479 seconds. Note that those pgen numbers stay consistent if you increase the power requirement, so reaching >60k power income just adds t3 pgens to those numbers (60k taking 269,93 seconds).

Im relatively sure that this is very close to the optimal time, the only way i see to improve it would maybe be moving an earlier t1 pgen to the back of the buildorder, but that would, if it gains any time, amount to an extremely small difference. If anyone has better ideas, tell me!


you are too clever, i need to refactor my question:

you start with an tech 1 acu, and no factory

no reclaim
infinite mass

so you have to factor in build power, but don't have to factor in movement inefficiencies.
randall172
Crusader
 
Posts: 27
Joined: 06 May 2019, 18:30
Has liked: 4 times
Been liked: 0 time
FAF User Name: ExpropriatorNoCompen

Re: MATH QUESTION

Postby Myxir » 20 Jun 2019, 11:25

seems interesting, so i wrote a script to check that

assumptions
- only t1 engineers, they are equally efficient as t2/t3 engies but built quicker
- starting with 4k e in storage, storage is infinite, the first building is always a factory
- using only navy facs, they cost the least power
- higher tech facs are inferior in eco/bp stats, so only t1 facs are ever built
- there are two upgrade paths: acu or factory. if factory is chosen, an additional engineer of that tech is required
- always using the highest tech available for pgns
- due to complexity, energy storages are ignored
- facs can only assist in building engies. if something else is built, the bp is wasted, as they do not build concurrently (for simplicity)

so i wrote a simple greedy hill climber to test that
- this is not guaranteed to be optimal in any case, but usually is somewhat close
- using pool size 5, means it generates offspring of the currently best one and mutates them randomly
- only the best performing one survives the current iteration
- each mutation either removes something from the queue, or inserts a random available object randomly into it
- using 10000 iterations for both upgrade path problems

results:
t = time, f_bp = buildpower of facs, e_bp = all other buildpower
eX = engy of tech X, pX = pgn of tech X, aX = acu upgrade to tech X, fX = fac of tech X (only t1), fXh = fac hq upgrade to tech X
the queues are split in 5 parts: t1, t2 transition, t2, t3 transition, t3
transition only matters for the ugprade path, when the queue is finished, t3 pgns are built until the e target is reached

acu upgrade path:
t: 367.30 e_prod: 30000 e_storage: 173838.8 f_bp: 100 e_bp: 1675
queue:
Spoiler: show
['e1', 'e1', 'e1', 'p1', 'e1', 'p1', 'e1', 'p1', 'e1', 'p1', 'p1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'p1', 'p1', 'e1', 'p1', 'e1', 'e1', 'p1', 'e1', 'e1', 'p1', 'e1', 'p1', 'p1', 'e1', 'e1', 'p1', 'e1', 'e1', 'p1', 'e1', 'p1', 'p1', 'e1', 'p1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'p1', 'p1', 'p1', 'f1', 'p1', 'e1', 'e1', 'p1', 'e1', 'p1', 'p1', 'e1', 'p1', 'e1', 'e1', 'p1', 'p1', 'p1', 'e1', 'p1', 'f1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'p1', 'p1', 'p1', 'e1', 'p1', 'e1', 'e1', 'p1', 'e1', 'e1', 'p1', 'e1', 'e1', 'p1', 'e1', 'p1', 'p1', 'p1', 'e1', 'p1', 'p1', 'p1', 'p1', 'e1', 'p1', 'f1', 'e1', 'p1', 'p1', 'e1', 'p1', 'p1', 'e1', 'p1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'p1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'p1', 'p1', 'p1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p1', 'e1', 'p1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p1', 'p1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1'], ['a2'], ['e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'f1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1'], ['a3'], ['e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p3', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p3', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p3', 'e1', 'e1', 'e1', 'e1']



fac+engy upgrade path:
t: 368.34 e_prod: 30020 e_storage: 154187.0 f_bp: 250 e_bp: 1742
queue:
Spoiler: show
['e1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'p1', 'p1', 'p1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'p1', 'p1', 'e1', 'e1', 'p1', 'e1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'p1', 'p1', 'e1', 'e1', 'e1', 'p1', 'p1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'p1', 'p1', 'e1', 'p1', 'e1', 'p1', 'p1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'p1', 'p1', 'e1', 'p1', 'p1', 'e1', 'e1', 'p1', 'p1', 'e1', 'e1', 'p1', 'p1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'p1', 'p1', 'p1', 'p1', 'e1', 'e1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'p1', 'p1', 'p1', 'e1', 'p1', 'p1', 'e1', 'e1', 'p1', 'f1', 'e1', 'e1', 'e1', 'p1', 'e1', 'p1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'p1', 'e1', 'p1', 'e1', 'f1', 'e1', 'e1', 'e1', 'e1', 'p1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1'], ['f2h', 'e2'], ['e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'f1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'f1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p2', 'p2', 'e1', 'e1', 'e1', 'e1', 'p2', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1'], ['f3h', 'e3'], ['e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p3', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p3', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p3', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'p3', 'p3', 'p3', 'p3', 'p3', 'p3', 'p3', 'p3', 'e1', 'p3', 'p3', 'f1', 'e1', 'e1', 'f1', 'p3', 'e1', 'e1', 'f1', 'p3', 'e1', 'p3', 'p3', 'f1', 'p3', 'p3', 'f1', 'p3', 'e1', 'e1', 'f1', 'f1', 'p3', 'e1', 'e1', 'f1', 'e1', 'p3', 'p3', 'f1', 'e1', 'p3', 'f1', 'p3', 'p3', 'f1', 'f1', 'p3', 'p3', 'p3', 'p3', 'e1', 'e1', 'e1', 'f1', 'e1', 'p3', 'p3', 'f1', 'f1', 'p3', 'f1', 'f1', 'p3', 'f1', 'p3', 'e1', 'e1', 'f1', 'f1', 'f1', 'f1', 'e1', 'p3', 'p3', 'p3', 'e1', 'f1', 'p3', 'e1', 'p3', 'e1', 'f1', 'p3', 'f1', 'e1', 'f1', 'p3', 'e1', 'e1', 'f1', 'f1', 'f1', 'e1', 'f1', 'p3', 'e1', 'e1', 'f1', 'f1', 'p3', 'p3', 'p3', 'p3', 'e1', 'f1', 'e1', 'e1', 'f1', 'p3', 'e1', 'e1', 'f1', 'e1', 'p3', 'e1', 'e1', 'e1', 'p3', 'f1', 'f1', 'e1', 'f1', 'e1', 'f1', 'f1', 'p3', 'e1', 'p3', 'f1', 'e1', 'p3', 'p3', 'p3', 'p3', 'f1', 'e1', 'p3', 'f1', 'e1', 'e1', 'e1', 'f1', 'e1', 'f1', 'f1', 'f1', 'p3', 'e1', 'e1', 'f1', 'p3', 'p3', 'f1']


in the current results, the acu upgrade path is just slightly faster
and interestingly, both paths have a lot of e in storage, means they are either not optimized enough, or idle facs while something else is built is really bad

if you want to fiddle around with that, knock yourself out: https://pastebin.com/Z31Fj2uu
each run takes only ~30s on my pc, so it's pretty quick to play around with
Unhappy with balance http://i.imgur.com/q5G2BlM.png
User avatar
Myxir
Evaluator
 
Posts: 791
Joined: 09 Apr 2012, 14:01
Has liked: 94 times
Been liked: 306 times
FAF User Name: Washy (irc)


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest