1 |
Well, here it is!
|
1 |
Well, here it is!
|
2 |
\n
|
2 |
\n
|
3 |
Computationally inexpensive, straightforward and so far passing all examples :D
|
3 |
Computationally inexpensive, straightforward and so far passing all examples :D
|
4 |
\n
|
4 |
\n
|
5 |
(I'll spare the derivation of these formulas, I already outlined it above).
|
5 |
(I'll spare the derivation of these formulas, I already outlined it above).
|
6 |
\n
|
6 |
\n
|
7 |
Input: [i]n[/i] mexes, mex incomes [i]m_i[/i], energy available for OD [i]E[/i]
|
7 |
Input: [i]n[/i] mexes, mex incomes [i]m_i[/i], energy available for OD [i]E[/i]
|
8 |
Output: Allocated energies per mex [i]e_i[/i]
|
8 |
Output: Allocated energies per mex [i]e_i[/i]
|
9 |
\n
|
9 |
\n
|
10 |
1. Calculate k = 1/(4 sqrt(E + 4 n)) * sqrt(sum(m_i²))
|
10 |
1. Calculate k = 1/(4 sqrt(E + 4 n)) * sqrt(sum(m_i²))
|
11 |
2. For each mex, set e_i = m_i²/(16 k²) - 4
|
11 |
2. For each mex, set e_i = m_i²/(16 k²) - 4
|
12 |
\n
|
12 |
\n
|
13 |
That's basically it.
|
13 |
That's basically it.
|
14 |
\n
|
14 |
\n
|
15 |
Exceptions:
|
15 |
Exceptions:
|
16 |
-This formula may result in negative e values, in which case the respective e_i should be set to 0 and the calculation restarted (this time omitting that particular mex that is not worth overdriving).
|
16 |
-This formula may result in negative e values, in which case the respective e_i should be set to 0 and the calculation restarted (this time omitting that particular mex that is not worth overdriving).
|
17 |
-If any grid doesn't hold enough e for the requested amounts, solve the problem for the grid locally (with E = the max e available in the grid) and redo the calculation for the remaining stuff (with the remaining energy). (This is basically what the current algorithm already does).
|
17 |
-If any grid doesn't hold enough e for the requested amounts, solve the problem for the grid locally (with E = the max e available in the grid) and redo the calculation for the remaining stuff (with the remaining energy). (This is basically what the current algorithm already does).
|
18 |
\n
|
18 |
\n
|
19 |
It will make sense to calculate the e_i beginning with the [i]smallest[/i] mexes, so that negative values can immediately be ruled out. k will have to be recalculated each time, but that's acceptable (applying that formula even for every mex should really not be a problem if you have all the m_i at hand).
|
19 |
It will make sense to calculate the e_i beginning with the [i]smallest[/i] mexes, so that negative values can immediately be ruled out. k will have to be recalculated each time, but that's acceptable (applying that formula even for every mex should really not be a problem if you have all the m_i at hand).
|
20 |
\n
|
20 |
\n
|
21 |
2 examples (2 mexes, 3 mexes) of cases without the exceptions:
|
21 |
2 examples (2 mexes, 3 mexes) of cases without the exceptions:
|
22 |
http://pastebin.com/b3AjS5HD
|
22 |
http://pastebin.com/b3AjS5HD
|
23 |
\n
|
23 |
\n
|
24 |
No more manual grid color balancing :)
|
24 |
No more manual grid color balancing :)
|
25 |
\n
|
25 |
\n
|
26 |
PS:
It's
sort
of
odd
to
notice
that
the
current
gadged
is
actually
quite
close,
seeing
as
it
uses
energy
proportional
to
m_i²,
too.
It's
just
(
sort
of)
missing
the
constant
term
there.
Well,
I
really
can't
get
a
decent
interpretation
out
of
that
formula
atm
(
although
i
notice
now
that
there's
some
cancellation
I
missed,
the
16
in
the
second
formula
is
pretty
unnecessary
if
you
just
cancel
it
with
the
first
4
in
the
first
formula)
.
|
26 |
PS:
It's
sort
of
odd
to
notice
that
the
current
gadged
is
actually
quite
close,
seeing
as
it
uses
energy
proportional
to
m_i²,
too.
It's
just
(
sort
of)
missing
the
constant
term
there.
Well,
I
really
can't
get
a
decent
interpretation
out
of
that
formula
atm
(
although
i
notice
now
that
there's
some
cancellation
I
missed,
the
16
in
the
second
formula
is
pretty
unnecessary
if
you
just
cancel
it
with
the
first
4
in
the
first
formula.
I'd
just
introduce
mistakes
if
I'd
attempt
to
change
it
now)
.
|
27 |
Also note that I have no proof for this formula thus far. The "equal derivatives" was just sort of empirical from 3 examples, please tell me if you manage to find a counter-example! (SCIENCE!)
|
27 |
Also note that I have no proof for this formula thus far. The "equal derivatives" was just sort of empirical from 3 examples, please tell me if you manage to find a counter-example! (SCIENCE!)
|
28 |
\n
|
28 |
\n
|
29 |
Well, that felt good. I need to do this stuff more often :P
|
29 |
Well, that felt good. I need to do this stuff more often :P
|