mars-sim / mars-sim

Mars Simulation Project Official Codebase
https://mars-sim.com
GNU General Public License v3.0
107 stars 38 forks source link

Standardise the use of Laboratory for Research #1286

Closed bevans2000 closed 6 months ago

bevans2000 commented 7 months ago

Is your feature request related to a problem? Please describe. There is a lot of duplicated logic in the Task classes that relate to performing research in a lab. The same methods are duplicated in numerous classes. Specifically PerformLaboratoryResearch, PerformMathematicalModeling & StudyFieldSamples. The code has been copy and pasted between classes however there is slightly different implementation for the same objective. This increases the maintenance having numerous copies of the same logic.

Describe the goal(s) you have in mind Consolidate the logic related to selection/management of a Lab into a single location reducing duplication and making maintenance easier. Also convert to the new impact approach of #1285.

Describe the solution you desire to see Create a abstract class called LabTask that represents completing a Task in a Lab. This can be the superclass of the Tasks that uses a lab, e.g. the 3 classes mentioned above. This would also hold the reference to the Lab. In addition it would implement the ResearchScientificStudy interface; further removing duplication in the subclasses.

bevans2000 commented 7 months ago

In addition, this will collate all the Task classes relating to Science into a new package ...core.science.tasks. This reflects the fact that the current home package of Tasks is very large and it's a references everything in the simulation. It is better design to have the Tasks closer to the entities that that they are manipulating.

bevans2000 commented 7 months ago

@mokun Found some time over the weekend to advance this and it has cleaned up the code a lot. I have added some sophisticated UnitTests as well to check the research tasks. I've uncovered a big improvement as well. The Lab interface just records the number of researchers which isn't ideal against an explicit capacity value. However why don't we drop this and just use the ActivitySpots associated to the Lab to control capacity? As Workers move to research they will claim an ActivitySpot and hence automatically we will be able to judge capacity much better. Or am I missing something?

mokun commented 7 months ago

The Lab interface just records the number of researchers which isn't ideal against an explicit capacity value.

Sure. A few other Functions are also doing similar thing.

What is the purpose of the occupancy of a building ?

I suppose I ask this question in the past.

It seems the occupancy of a building is just an ideal number.

Since there's no fire safety building codes developed on Mars yet, it serves no real purpose.

Granted, the HVAC is supposed to be able to handle the moisture and heating, etc.

For smaller settlement, people may need to cramp in one tiny building for a meeting.

So how do you account for the exception such as having a meeting or in case of emergency, such as emergency repair and during or after meteorite impact ?

bevans2000 commented 7 months ago

We only should use spots for the Functions. So repairs do not need them.

For large meetings the required building category has to be suitable like dining or living. Then the logic picks the best building to host it. It could be adjusted to make sure the building has the capacity for the target attendance.

I am going to change Lab so it uses the Spot concept to do capacity. It makes more sense because spots are automatically released.

mokun commented 7 months ago

building has the capacity for the target attendance.

But how do you define what the capacity is for a building ?

Guess in case of mars-sim, we don't want to have two persons or bots overlapping the same spot.

So the discrete # of spots available is driving the capacity.

In real world, it's never discrete. Rather it's continuous and I can always slip in between people.

So we could come up with a way to introduce intermediate spots. When the normal spots are full, they can go to these intermediate spots.

bevans2000 commented 7 months ago

Yes for a Building I agree capacity is vague and essentially governed by the life support capacity. But for a Function like Research, the capacity is governed by the number of spots. If a lab only has 4 work stations then no more than 4 pieces of research can be done. Same for Accommodation with beds and Airlocks.

bevans2000 commented 7 months ago

Anyway I'm slowly working on the Tasks at the moment to consolidate and improve them with unit tests