• Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Welcome to OpenComputers

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more!

This message will be removed once you have signed in.

  • Announcements

    • Lizzy Trickster

      Latest Stable OpenComputers Version   11/26/16

      The latest released version of OpenComputers is version 1.6.1 for MC 1.7.10, 1.8.9, 1.9.4 & 1.10.2. See more information here! Beta/Dev builds can be found at the Jenkins Build Server (ci.cil.li)
XyFreak

Big Reactors Grid Control

40 posts in this topic

@XyFreak 20x20x8 with control rods every other block with a single block between them and the wall, full of copper blocks from ic2 on the inside. glass on all sides, solid top and bottom, with the computer port, reactor controller, and an in and output. IT is on the extreme reactors mod.

Share this post


Link to post
Share on other sites

Ok, while I wasn't able to gather the exact reactor design from what you described, I managed to build a somewhat similar reactor that triggers something that I believe is the same issue.

I can't believe I've overlooked that >_>. I dunno how long this is going to take me to fix but i'm working on it.

Share this post


Link to post
Share on other sites

Okidoki, I fixed it!

Unfortunately, you'll have to redownload the installer to upgrade to 4.1.

I'll post the story tomorrow, I need some rest now. Have this changelog in the mean time:

4.0.1 -> 4.1
 - Fixed a bug where turbines that are being calibrated can be suspended
 - Fixed a design bug where the performance prediction for passive reactors was based on linear regression.
   BRGC now has the ability to do polynomial interpolation.
 - Because the polynomial interpolation is THAT GOOD we can do numerical reactor optimization based on the polynomial.
   OPTIMIZATION-mode has been removed. This also fixes all issues of the OPTIMIZATION-mode (obviously).

 

-XyFreak

Share this post


Link to post
Share on other sites
2 hours ago, BatouOfNexus said:

This fixed the problem I was having with a 3x3x3 and a 21x21x21 (including casing) not finishing optimization. You fixed it before I could post about it!

This later crashed on line 174 of libGUI with a nil paramater when a string was expected.  The post with the exact details got eaten as apparently you can't copy text out of the edit box to the clipboard...

Share this post


Link to post
Share on other sites

WARNING! This post is long and contains math! Continue at your own risk!
There's also a TL;DR!

Once upon a time, XyFreak tried to came up with ideas how to predict the energy/steam output of a Big Reactor.
His test reactor was a small 7x7x2 reactor.
He played around with some settings and thought "cool! If I pull out the rods by 10, the output goes up by roughly 10%. There HAS to be a linear correlation!". Not knowing what he's doing, he just went on and wrote some code for his Big Reactors Grid Control program.
In his attempts to make BRGC work out of the box, he came up with a way to figure out the sweet spot of passive reactors. He knew that with really unbalanced reactors the algorithm may have some issues but...who uses unbalanced reactors anyways, right?
His ideas seemed to work perfectly. He and his friends used his program with many different actively cooled generators and everything worked as intended.
Time passed, Minecraft 1.7.10 was nearing the end of its lifespan. Minecraft 1.10.2 emerged!
Suddenly, "Gelid Cryotheum" was gone! Reactors have become a lot less balanced and many people emerged that found actively cooled reactors to be a hassle.
But there was a problem: For some reason, less balanced reactors didn't quite work as intended.
"Yeah right... I'm an idiot.", XyFreak thought. His past lazyness came to bite him in the a**. He opened up his Visual Studio Code (Use it! It's great!) and started reworking his algorithm. But something was not right. For some reason, all his attempts to improve the algorithm failed! Either the controller undershoots the power target or overshoots it by... a lot.
He looked at the calibration data of his (now bigger) test reactor and saw a value twice as large as it should've been (again, http://br.sidoh.org is your friend).
And this is where the tale of advanced mathematics begins for real.

And this is also where I stop writing in story telling mode :P

So, I told you above that I assumed the reactors output (be it energy or steam) to be linear in regards to the rod level.
Well... for actively cooled reactors this is true (or at least a near perfect approximation). And since I mostly used actively cooled reactors (both in my real playthroughs and my test worlds) everything worked fine.
And since my passive test reactor was so small and well balanced, it worked there as well.
Now.... look at this image here:

samples.png

This graph shows the energy output plotted against the (inverse) rod level. Doesn't look linear, does it? It's not linear at all!
I assumed the energy production to be linear, but the fuel consumption would go up dramaticaly as heat increases. Turns out it is the other way around! (Stupid me!)
Fuel consumption is linear with rod level but energy production decreases greatly as heat increases.

So... if it's not linear, what is it? Well... a polynomial 3rd degree seems to fit extremely well.
samples_polynomial.png

But how do you get such a polynomial? "Heh! Easy! We did this at high school!" you may think and that's what I thought as well.
<MATH WARNING!>
If you have N samples for x and f(x) you can easily create a polynomial of degree N-1. There're a couple of different methods to do it.
Now.. I don't have 4 samples, I have 17! "Easy! Just leave out some!". Yeah right....
I tried that and all polynomials sucked. Also, the polynomial libreoffice calculated seemed to fit perfectly. I wanna do that too!

After a while it struck me: It's a linear optimization problem (Of course it is! But it's been a while since I last worked with those, sorry.)
So...how to solve it?... ... ... QR decomposition...
Great! Now I'll have to do linear algebra in lua.

I always wanted to avoid using advanced math in brgc and now I have to work with matrices... great!

So...what do I need first? Right... matrices in lua. So I wrote a small library to work with matrices and the operations (and only those) I'm going to need to get QR decomposition working.
Next up? QR decomposition! But how does it work again? It's been a while since I last did something with that (at least 4 years).
Fortunately, Google is your friend (I'll append the links to the end of this post in case you're interested).
After 4 hours of implementation and debugging, everything worked. Well that was easy...not.

Next up: We're going to have to work with polynomials. So we need a library for that as well, right? 10 Minutes later: done.
I fed everything with my sample reactor values aaaaand....perfect!

Now...we got a nice way to interpolate functions. Maybe we can use it for the optimization as well?
Let's see...

Let the reactors efficiency denoted by E(p) = O(p) / C(p)
Where p is the percentage of the inverted rod insertion level, O(p) is a function that gives us the energy generation for rod level p and C(p) gives us the fuel _c_onsumption for rod level p.
O(p) is a polynomial of degree 3 and C(p) is of form C(p) = a * p. So we just devide two polynomials, right? How bad can it be.
I'll spare you the details, it's not worth it. The result is NOT a polynomial (well duh!).

BUT! Turns out we can use polynomial interpolation if we feed the interpolator the rod level and the efficiency values as samples (we already got those from the calibration).
Now we have a polynomial that describes the reactors efficiency!

efficiency.png
(We want to figure out the peak of that little mountaint)

For optimization purposes we're interested in the local maxima of that polynomial between 0 and 1 (0 = reactor off, 1 = reactor max). Thankfully, this is easy!
Thanks to the QR decomposition, the numerical calulus lecture was still on my mind and we did that stuff as well.
And when I'm saying "easy" I mean it. Take this code:

function polynomial.converge(polynomial, x, iterations)
	local df1 = polynomial:derivate()
	local df2 = df1:derivate()

	local dx = 0 - df1:eval(x) / df2:eval(x)
	for i=1, iterations do
		x = x - df1:eval(x) / df2:eval(x)
	end
	return x
end

That's the code. Here's some background, if you like: https://en.wikipedia.org/wiki/Newton%27s_method_in_optimization

DONE! Does everything work? Hell yes it does! This time I tested it with multiple designs and on 1.7.10 and 1.10.2.


TL;DR

XyFreak assumed stuff about reactors that's complete bullshit. It never came to light because his testing sucked.
Magic (math) happened. Stuff now works perfectly fine. Optimization-mode is gone. Everything is awesome.

Also:
I'd like to mention that I've now officially used more university knowledge to develop Big Reactors Grid Control than I've ever used in my day job.
So kids...keep this in mind: Pay attention in school! You may not need it in real life. But you may need it in Minecraft someday!

If you read everything, thanks for staying with me :)

-XyFreak


QR decomposition links (german)
http://www.math.uni-frankfurt.de/~numerik/lehre/Seminare/ProSem_MA_SS11/qrzerlegung.pdf
http://numerik.uni-hd.de/~lehre/SS12/numerik0/12-la-5.pdf
http://www.mathematik.uni-muenchen.de/~lerdos/SS08/Num/trans4.pdf

Share this post


Link to post
Share on other sites

Nice post and summary!  Thanks for the quick turn around.

 

FYI, you should see the math in a real reactor...  I was in the naval nuclear power program and even with 'dumbed down' math for enlisted men, one problem took the class an average of 8 hours to finish...

Share this post


Link to post
Share on other sites

Haha yeah. But this is a game and I've been told I put way too much effort in this already :P

I mean..comeon...who does that kinda stuff "just for minecraft", right? ;)

 

EDIT:

I wrote an entire gui library for this program as well. And there's some secure networking stuff I've been working on but never got around to finish.

Share this post


Link to post
Share on other sites

I would not classify it as 'just for Minecraft' personally.  It's experience programming that can be used later.  It also something you can point to on a resume that will show an employer that you can handle complicated problems.  Plus, if it's fun, that is it's own reward.

Share this post


Link to post
Share on other sites

That's a valid point but from personal experience, once should not mention "minecraft" on your resume. Just putting up "has expierience in programming language x with y, z" works better :P

But yeah, it's fun. However the fun ends if critical bug reports come in. I released this code to everyone so I feel obligated to fix code-breaking bugs ASAP.

This was one of these where I essentially stopped doing everything else and focused on fixing this problem.

It was worth it though ;) (Getting everything back running again is incredible rewarding)

Share this post


Link to post
Share on other sites

Hi,

i downloaded the program and tried to make use of it for a extreme reactor (1.10). What cables to I have to connect where?

I'm struggling with connecting the computer and the reactor..

Share this post


Link to post
Share on other sites

Hi Zinne91,

you connect your Reactor Computer Port with your computer by using a OpenComputer cables. No adapters required. Just connect it directly.

If you're using servers (the in-game one) then don't forget to connect the server to the proper side in the server rack gui.

 

-XyFreak

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now