Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a separate FishFarm Function #320

Closed
bevans2000 opened this issue Feb 22, 2021 · 35 comments
Closed

Create a separate FishFarm Function #320

bevans2000 opened this issue Feb 22, 2021 · 35 comments
Assignees

Comments

@bevans2000
Copy link
Member

Is your feature request related to a problem? Please describe.
Move the fish farming and bee keeping to separate Building Functions. This allows a new Building of FishFarm to be created and bees to be used in only the bigger greenhouses.
Also this will allow the creation of new Tasks to replenish the fish and honey stocks.

@bevans2000 bevans2000 self-assigned this Feb 22, 2021
@bevans2000
Copy link
Member Author

As part of this work I think I've uncovered a mistake in the logic concerning ResourceProcess. The ResourceProcess instances are created in BuildingConfig and shared for the same the Building Type. The ResourceProcessing function class then retrieves the ResourceProcess objects according to the parent Building Type and then owners them. However if another Buliding of the same type is created; it will also use the same ResourceProcess instances. This means that they both update the same set of ResourceProcess during the time pulse and Task work creating chaos.
To resolve this I am going to split out the configuration properties into a new ResourceProcessSpec which can be shared and is immutable. The ResourceProcess objects will be created and owned by the individual ResourceProcessing objects.

@mokun
Copy link
Member

mokun commented Feb 25, 2021

Link this to its discussion

@mokun
Copy link
Member

mokun commented Feb 25, 2021

As part of this work I think I've uncovered a mistake in the logic concerning ResourceProcess. The ResourceProcess instances are created in BuildingConfig and shared for the same the Building Type. The ResourceProcessing function class then retrieves the ResourceProcess objects according to the parent Building Type and then owners them. However if another Buliding of the same type is created; it will also use the same ResourceProcess instances. This means that they both update the same set of ResourceProcess during the time pulse and Task work creating chaos.

Great that you caught this.

I'm also wondering why the cpu utility spiked up since we started implementing the settlement partition in concurrent threads. Any particular reasons ?

To resolve this I am going to split out the configuration properties into a new ResourceProcessSpec which can be shared and is immutable. The ResourceProcess objects will be created and owned by the individual ResourceProcessing objects.

Question, if we one day implement the object database for storing values, would we still be using these Inventory-related class ?

@bevans2000
Copy link
Member Author

So I've found a potentially even bigger problem but I'm not sure. The Building class is serialised in a simulation save but none of the Function objects are; they are only reference via a transient List. This means each time a simulation is reloaded the Functions are recreated, for example Farming will pick a new random set of Crops. Any state that is held in teh Function objects or their child objects is lost when a simulation is saved & reloaded.
Is this correct?

@mokun
Copy link
Member

mokun commented Feb 26, 2021

So I've found a potentially even bigger problem but I'm not sure. The Building class is serialised in a simulation save but none of the Function objects are; they are only reference via a transient List. This means each time a simulation is reloaded the Functions are recreated, for example Farming will pick a new random set of Crops. Any state that is held in teh Function objects or their child objects is lost when a simulation is saved & reloaded.
Is this correct?

True that building functions aren't serialized.

I wonder how it would affect the greenhouse crops since I thought the crops are serialized

bevans2000 added a commit that referenced this issue Feb 26, 2021
Add a new BuilindgCommand and ProcessCommand the console.

#320
@bevans2000
Copy link
Member Author

I have done a couple of tests and the Crops are different after a reload. If the Crops are not referenced by a serialised object they will not be saved. Moreover, the Farming class is rebuilt in the Building.
On face value this is easy to fix by removing the transient from the functions property in the Building class. However this might cause problems on the reload due to the very complex reference graph. The main culprit is the large number of Collections to Person objects. The way to fix this could be to create our own PersonSet class that implements lazy loading. It stores unit identifiers when it is serialised but exposes the Person object at runtime. This pattern could be applied to all Units Collections over time.
Nevertheless, this needs a separate issue if we are to solve it.... but I think we need to.

bevans2000 added a commit that referenced this issue Feb 27, 2021
Each ResourceProcessing function has it's own dedicated processes now so
they can be controlled individually. Also fixed a bug that stopped
anyone doing ToggleResourceProcess tasks.
Also allowed the toggle duration & minimum period to be set via the
building.xml. The big 'Solid Waste' processes have a larger toggle
duration and periodicity.
#320
@mokun
Copy link
Member

mokun commented Feb 27, 2021

I have done a couple of tests and the Crops are different after a reload. If the Crops are not referenced by a serialised object they will not be saved. Moreover, the Farming class is rebuilt in the Building.

I've wanted to make the Building objects smaller by not serializing the Function. The list of Function(s) is the same for each type of Building.

On face value this is easy to fix by removing the transient from the functions property in the Building class. However this might cause problems on the reload due to the very complex reference graph.

But I probably fail to account for how greenhouse and other functions do have persistent objects that need to be serialized.

The main culprit is the large number of Collections to Person objects. The way to fix this could be to create our own PersonSet class that implements lazy loading. It stores unit identifiers when it is serialised but exposes the Person object at runtime. This pattern could be applied to all Units Collections over time.

So, how or in what fashion do we organize what to be serialized ?

Java serialization has some built-in ability to simplify the serialization graph but we better not rely on it too much, since we are moving toward the JSON serialization.

From the perspective of each settlement, what minimal things does it want to be serialized through the simulation ?

From the perspective of each person, what minimal things does it want to be serialized through the simulation ?

I have wanted to work toward saving each person as a personID, and each settlement as a settlementID but haven't fully considered many factors involved.

I suppose in future it makes sense to have flexibility in "transferring" out a person from one simulation to the other.

@bevans2000
Copy link
Member Author

Functions and the objects they reference have state so they need to be saved.
Saving just the Person identifiers makes sense because it will slightly reduce the save size but the big benefit is it reduces the object references when reloading. We can hold Person collections in a dedicated new class allowing a Person reference to be held in memory but only serialised the ids.

bevans2000 added a commit that referenced this issue Mar 4, 2021
Added a new building type to the building.xml & updated settlements.xml
to add the the template.
Building UI Panel now has a Fishery panel to support the new Function.
The new TendFishTank task now delays the tending weeds phase so it does
not trigger all the time.
#320
@mokun
Copy link
Member

mokun commented Mar 5, 2021

Great that you added TendFishTank and TendFishTankMeta.

Now the Biologists/botanists have new tasks to do.

Btw, the TendGreenhouse has issues with TaskPhase switching. It switches too fast and doesn't stay in one TaskPhase for a good duration of time.

I envision TaskPhase as just one type of minor tasks within a major task and there can be a number of minor tasks to choose from.

So, say you give me 15 millisols for TendGreenhouse, I may only be able to do one minor task and I choose "inspecting" in the first round.

Next time when I come back, I'll do "cleaning".

@bevans2000
Copy link
Member Author

Yes the task needs some tuning. Also any fish caught are not added to the inventory yet

@mokun
Copy link
Member

mokun commented Mar 6, 2021

Yes the task needs some tuning. Also any fish caught are not added to the inventory yet

@bevans2000 ,

Can you commit all the changes made so far ?

Even though it's not 100% complete, it's better for me to start from the latest copy of mars-sim you have.

There are few things in other areas I'd like to change.

bevans2000 added a commit that referenced this issue Mar 6, 2021
Caught Fish are added to Settlement Inventory as fish meat & fish oil.
#320
@bevans2000
Copy link
Member Author

I'm pretty happy with this last commit. I have reworked the BuildingConfig to consolidated the numerous common attributes. This has removed a lot of duplicate code. I will merge the changes on the branch now and then tidy up any snags.

@bevans2000
Copy link
Member Author

I should have said. I haven't got the Unit Test working yet because they use a non-existent Building Type which breaks everything in the walking tests. This should be easy to fix tomorrow by making MockBuilding a real configured type. Also each test has the same initialisation code so it should be using a @Setup method.

@mokun
Copy link
Member

mokun commented Mar 6, 2021

@bevans2000 ,

By the way, we may as well update our wiki on Food Production as we are working on getting the fishery and beehive to work.

@bevans2000
Copy link
Member Author

Sure good point

@mokun
Copy link
Member

mokun commented Mar 10, 2021

Right now, by default we give New Pompeii a fish farm.

I was thinking of making fish farm initially available to a Japan Aerospace Exploration Agency (JAXA)'s settlement because they would love to make sushi out of the fish :D

image

Also, see the red box in the pic above, the Tank Size should be 10000 but right next to it, there's an artifact that looks like a "|" symbol.

Q: If we allow players to tweak things in a fishery, what do you see fit that can be adjusted ?

I know at some point in future, we would for sure have different species of fish for the player to experiment with.

If that's the case, we may as well now think of beneficial changes to our UI that will be more intuitive and for players to change parameters in a fishery, just like in a game or in a simulation application.

@Urwumpe
Copy link
Contributor

Urwumpe commented Mar 10, 2021

Do we already have recipes for making Sushi meals? If not, we need a new ticket for that and I'll have to do some ...well... "research" (yummy) today.

@bevans2000
Copy link
Member Author

Also, see the red box in the pic above, the Tank Size should be 10000 but right next to it, there's an artifact that looks like a "|" symbol.

Hahaha. It is actually an 'l' meaning litres. Just doesn't come out very well. I'll change it to the work 'litres' to make it clearer.

The actual number needs some adjusting. 10K was an initial guess; 10K litres would occupy a tank that is 10m2 which is probably smaller that the dedicated Fish Farm building could hold. But they can not be too high; they need a large surface area.
Also there is a ratio of 1 fish per 10 litres as the initial startup which is just a guess. This has to actually be based on the size of fish and surface area. This would give a maximum stock level so the initial starting stock should be 80% to allow some growth.

@Urwumpe
Copy link
Contributor

Urwumpe commented Mar 10, 2021

Also, see the red box in the pic above, the Tank Size should be 10000 but right next to it, there's an artifact that looks like a "|" symbol.

Hahaha. It is actually an 'l' meaning litres. Just doesn't come out very well. I'll change it to the work 'litres' to make it clearer.

The actual number needs some adjusting. 10K was an initial guess; 10K litres would occupy a tank that is 10m2 which is probably smaller that the dedicated Fish Farm building could hold. But they can not be too high; they need a large surface area.
Also there is a ratio of 1 fish per 10 litres as the initial startup which is just a guess. This has to actually be based on the size of fish and surface area. This would give a maximum stock level so the initial starting stock should be 80% to allow some growth.

Well, 10 cubic meters is a lot of water, if it has to be produced on Mars or be transported from Earth. If the aquaponics start with shrimp, even far less water could be enough for a small sustainable production.

@bevans2000
Copy link
Member Author

I'm also having second thoughts about bee keeping as well. There is a lot of nature we have to consider to have bees. It's easier to add a new Function to cover bee keeping but I have no idea on how to model the honey creation; it is very dependent upon what crops are in the Greenhouse and the greenhouses are not big enough to support a hive from what I have read so far.

@Urwumpe
Copy link
Contributor

Urwumpe commented Mar 11, 2021

Yeah, though I think it COULD work out with vertical farming and a really huge greenhouse - and maybe a more resourceful species of bees. Sure nothing that can be constructed easily. Especially on Mars.

@bevans2000 bevans2000 changed the title Create a separate FishFarm & BeeHive Function Create a separate FishFarm Function Mar 11, 2021
@mokun
Copy link
Member

mokun commented Jun 18, 2021

@bevans2000 ,

Can we have the algae farm ?

Do you see that it can be modeled similarly as fish farm ?

@mokun
Copy link
Member

mokun commented Jun 18, 2021

we could have either algae ponds, on growing algae in rows and columns of bags. I've seen research journal that use bags of algae as a part of the waste removal system.

They have wanted to genetically engineer algae to also absorb surface radiation. That's why these bags are designed to be fitted in between the outer and inner wall of a hab.

@bevans2000
Copy link
Member Author

I don't see why it couldn't be modelled in a similiar fashion. It could just be a Function applied to a Building.

@mokun
Copy link
Member

mokun commented Jun 18, 2021

I don't see why it couldn't be modelled in a similiar fashion. It could just be a Function applied to a Building.

Sure. does it warrant a brand new building function ? or reuse the old farming function ?

@mokun
Copy link
Member

mokun commented Jun 18, 2021

@bevans2000 , btw, can you add the version tag info with your name to all the new class files you have created in the last few months ? I've helped adding that back in some but not all.

@bevans2000
Copy link
Member Author

Sure

@bevans2000
Copy link
Member Author

I don't see why it couldn't be modelled in a similiar fashion. It could just be a Function applied to a Building.

Sure. does it warrant a brand new building function ? or reuse the old farming function ?

I like the idea if a new Fubction because it gives us flexibility to apply it any building, maybe a new dedicated one or existing buildings as isolation bags.

@mokun
Copy link
Member

mokun commented Oct 25, 2021

I took the liberty of capturing the pic below from a recent Mars Society conference:
image

Mars Aquaponics System - Carl Greenbaum - 2021 Mars Society Virtual Convention
Oct 22, 2021
See link

@mokun
Copy link
Member

mokun commented Oct 27, 2021

Just added filet sandwich and sushi plate in this commit.

@mokun
Copy link
Member

mokun commented Oct 27, 2021

Is there a way to control or change the rate of harvesting of fish both automatically and manually ?

We can add a vertical number slider field for adjusting the harvest rate and checkboxes for tweaking the max and min number of fishes, etc.

@mokun
Copy link
Member

mokun commented Oct 27, 2021

Btw, I'm also thinking of adding some control for revealing and the ability of adjusting the food and water consumption for each settlement.

We already have ability to automate the water ration if water goes low.

We could do the same for food rationing.

Players can see the rate at which food and water is consumed and can manually adjust this rate.

@bevans2000
Copy link
Member Author

Just added filet sandwich and sushi plate in this commit.

Nice

@mokun
Copy link
Member

mokun commented Sep 20, 2023

Even though there's 146 fish, it sounds unreasonable to have given much (namely, 869 kg) weed inside the tank.

image

@mokun
Copy link
Member

mokun commented Sep 20, 2023

Btw, I'm committing my algae pond in a moment.

mokun added a commit that referenced this issue Nov 24, 2023
11.22.2023

- new: add AlgaeCommand
- change: adopt scoring on inspections and cleanliness for fishery,
          algae farming and crop tending greenhouse

Note: this commit changes the value of the cleaning and inspection maps
      as cleanliness score and inspectable condition score

Relates to #320 and #986
mokun added a commit that referenced this issue Dec 7, 2023
12.07.2023

- change: vary the starting # of fish to only 5% to 15% of what it
          used to be
- change: rework tendWeeds() in Fishery to grow the weeds
- change: rework TendFishTankMeta and TendFishTank
- change: revise OptimizeSystem and OptimizeSystemMeta
- change: add show water mass and work time in BuildingPanelFishery

Relates to #320 and #986
mokun added a commit that referenced this issue Dec 8, 2023
12.07.2023

- change: reduce worktime in Fishery
- change: reduce weed demand in TendFishTankMeta
- change: vary fresh water to be added in AlgaeFarming
- change: add showing # of weed and total fish weight in
          BuildingPanelFishery
- change: call Animal's growPerFrame() with param time, instead of
		  calling Organism's growPerFrame() without param

Relates to #320, #986, #1169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants