Skip to content

Commit b644d9c

Browse files
committed
set daughter critVol from birth volume in GMC differentiation
1 parent 9238f51 commit b644d9c

4 files changed

Lines changed: 73 additions & 6 deletions

File tree

src/arcade/potts/agent/cell/PottsCellFlyGMC.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,41 @@ public PottsCellContainer make(int newID, CellState newState, MersenneTwisterFas
5555
criticalRegionHeights);
5656
}
5757

58+
/**
59+
* Creates a container for a new daughter cell with an explicit critical volume.
60+
*
61+
* <p>Unlike {@link #make(int, CellState, MersenneTwisterFast)}, which copies this cell's
62+
* critical volume, this overload lets the caller set the daughter's critical volume from the
63+
* volume it is actually born into rather than inheriting the parent's.
64+
*
65+
* @param newID the daughter cell ID
66+
* @param newState the daughter cell state
67+
* @param critVol the critical volume assigned to the daughter cell
68+
* @param random the random number generator
69+
* @return a container for the daughter cell
70+
*/
71+
public PottsCellContainer make(
72+
int newID, CellState newState, double critVol, MersenneTwisterFast random) {
73+
divisions++;
74+
75+
int newPop = links.next(random);
76+
77+
return new PottsCellContainer(
78+
newID,
79+
id,
80+
newPop,
81+
age,
82+
divisions,
83+
newState,
84+
null,
85+
0,
86+
null,
87+
critVol,
88+
criticalHeight,
89+
criticalRegionVolumes,
90+
criticalRegionHeights);
91+
}
92+
5893
@Override
5994
void setStateModule(CellState newState) {
6095
switch ((State) newState) {

src/arcade/potts/agent/module/PottsModuleFlyGMCDifferentiation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ void addCell(MersenneTwisterFast random, Simulation sim) {
8585

8686
// Create and schedule new neuron cell
8787
int newID = sim.getID();
88-
CellContainer newContainer = cell.make(newID, State.QUIESCENT, random);
88+
CellContainer newContainer =
89+
((PottsCellFlyGMC) cell)
90+
.make(newID, State.QUIESCENT, newLocation.getVolume(), random);
8991
PottsCell newCell =
9092
(PottsCell) newContainer.convert(sim.getCellFactory(), newLocation, random);
9193
sim.getGrid().addObject(newCell, null);
@@ -113,7 +115,7 @@ void addCell(MersenneTwisterFast random, Simulation sim) {
113115
null,
114116
0,
115117
null,
116-
oldCell.getCriticalVolume(),
118+
location.getVolume(),
117119
oldCell.getCriticalHeight(),
118120
oldCell.getCriticalRegionVolumes(),
119121
oldCell.getCriticalRegionHeights());

test/arcade/potts/agent/cell/PottsCellFlyGMCTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,26 @@ public void make_called_returnsCorrectNewContainer() {
125125
() -> assertNull(container.criticalRegionVolumes),
126126
() -> assertNull(container.criticalRegionHeights));
127127
}
128+
129+
@Test
130+
public void make_withExplicitCritVol_usesProvidedCritVol() {
131+
PottsCellFlyGMC gmc =
132+
new PottsCellFlyGMC(baseContainer, locationMock, parametersMock, links);
133+
double explicitCritVol = cellCriticalVolume + 50.0;
134+
PottsCellContainer container = gmc.make(cellID, State.QUIESCENT, explicitCritVol, random);
135+
assertAll(
136+
() -> assertNotNull(container),
137+
() -> assertEquals(cellID, container.parent),
138+
() -> assertEquals(1, container.pop),
139+
() -> assertEquals(cellAge, container.age),
140+
() -> assertEquals(cellDivisions + 1, container.divisions),
141+
() -> assertEquals(State.QUIESCENT, container.state),
142+
() -> assertNull(container.phase),
143+
() -> assertEquals(0, container.voxels),
144+
() -> assertNull(container.regionVoxels),
145+
() -> assertEquals(explicitCritVol, container.criticalVolume, EPSILON),
146+
() -> assertEquals(cellCriticalHeight, container.criticalHeight, EPSILON),
147+
() -> assertNull(container.criticalRegionVolumes),
148+
() -> assertNull(container.criticalRegionHeights));
149+
}
128150
}

test/arcade/potts/agent/module/PottsModuleFlyGMCDifferentiationTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,18 @@ final void tearDown() {
133133

134134
@Test
135135
public void addCell_called_callsExpectedMethods() {
136-
// When the module calls make() on the cell, return Quiescent PottsCellContainer
137-
// mock
136+
double newLocVol = 42.0;
137+
double locVol = 50.0;
138+
when(newLocation.getVolume()).thenReturn(newLocVol);
139+
when(location.getVolume()).thenReturn(locVol);
140+
141+
// When the module calls make() on the cell, return Quiescent PottsCellContainer mock
138142
container = mock(PottsCellContainer.class);
139-
when(gmcCell.make(eq(123), eq(State.QUIESCENT), any(MersenneTwisterFast.class)))
143+
when(gmcCell.make(
144+
eq(123),
145+
eq(State.QUIESCENT),
146+
eq(newLocVol),
147+
any(MersenneTwisterFast.class)))
140148
.thenReturn(container);
141149
newCell = mock(PottsCell.class);
142150
when(container.convert(eq(cellFactory), eq(newLocation), any(MersenneTwisterFast.class)))
@@ -147,7 +155,7 @@ public void addCell_called_callsExpectedMethods() {
147155
module.addCell(random, sim);
148156
verify(location).split(random);
149157
verify(gmcCell).reset(dummyIDs, dummyRegions);
150-
verify(gmcCell).make(123, State.QUIESCENT, random);
158+
verify(gmcCell).make(123, State.QUIESCENT, newLocVol, random);
151159

152160
verify(grid).addObject(newCell, null);
153161
verify(potts).register(newCell);

0 commit comments

Comments
 (0)