-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent DrawFromLocationValuePlannedActionGenerator from returning il…
…legal actions
- Loading branch information
1 parent
f385504
commit 9f151e9
Showing
13 changed files
with
141 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
/* | ||
* POSEIDON, an agent-based model of fisheries | ||
* Copyright (c) 2024-2024 CoHESyS Lab [email protected] | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package uk.ac.ox.oxfish.fisher.purseseiner.planner; | ||
|
||
import com.google.common.base.Preconditions; | ||
import ec.util.MersenneTwisterFast; | ||
import uk.ac.ox.oxfish.biology.GlobalBiology; | ||
import uk.ac.ox.oxfish.biology.LocalBiology; | ||
import uk.ac.ox.oxfish.fisher.Fisher; | ||
import uk.ac.ox.oxfish.fisher.purseseiner.actions.CatchMaker; | ||
import uk.ac.ox.oxfish.fisher.purseseiner.samplers.CatchSampler; | ||
import uk.ac.ox.oxfish.fisher.purseseiner.strategies.fields.LocationValues; | ||
|
@@ -26,6 +42,7 @@ public abstract class CatchSamplerPlannedActionGenerator<PA extends PlannedActio | |
private final Class<B> localBiologyClass; | ||
|
||
CatchSamplerPlannedActionGenerator( | ||
final Fisher fisher, | ||
final LocationValues originalLocationValues, | ||
final NauticalMap map, | ||
final MersenneTwisterFast random, | ||
|
@@ -35,7 +52,7 @@ public abstract class CatchSamplerPlannedActionGenerator<PA extends PlannedActio | |
final GlobalBiology biology, | ||
final Class<B> localBiologyClass | ||
) { | ||
super(originalLocationValues, map, random); | ||
super(fisher, originalLocationValues, map, random); | ||
this.additionalWaitTime = additionalWaitTime; | ||
this.howMuchWeCanFishOutGenerator = howMuchWeCanFishOutGenerator; | ||
this.catchMaker = catchMaker; | ||
|
@@ -44,7 +61,7 @@ public abstract class CatchSamplerPlannedActionGenerator<PA extends PlannedActio | |
} | ||
|
||
@Override | ||
public PA drawNewPlannedAction() { | ||
protected PA locationToPlannedAction(final SeaTile location) { | ||
Preconditions.checkState(isReady(), "Did not start the deploy generator yet!"); | ||
return | ||
turnSeaTilePickedIntoAction( | ||
|
@@ -72,6 +89,7 @@ public static class DolphinActionGenerator<B extends LocalBiology> | |
private final int rangeInSeaTiles; | ||
|
||
DolphinActionGenerator( | ||
final Fisher fisher, | ||
final LocationValues originalLocationValues, | ||
final NauticalMap map, | ||
final MersenneTwisterFast random, | ||
|
@@ -83,6 +101,7 @@ public static class DolphinActionGenerator<B extends LocalBiology> | |
final int rangeInSeaTiles | ||
) { | ||
super( | ||
fisher, | ||
originalLocationValues, | ||
map, | ||
random, | ||
|
@@ -124,6 +143,7 @@ public static class NonAssociatedActionGenerator<B extends LocalBiology> | |
private final int rangeInSeaTiles; | ||
|
||
NonAssociatedActionGenerator( | ||
final Fisher fisher, | ||
final LocationValues originalLocationValues, | ||
final NauticalMap map, | ||
final MersenneTwisterFast random, | ||
|
@@ -136,6 +156,7 @@ public static class NonAssociatedActionGenerator<B extends LocalBiology> | |
final int rangeInSeaTiles | ||
) { | ||
super( | ||
fisher, | ||
originalLocationValues, | ||
map, | ||
random, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
/* | ||
* POSEIDON, an agent-based model of fisheries | ||
* Copyright (c) 2024-2024 CoHESyS Lab [email protected] | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package uk.ac.ox.oxfish.fisher.purseseiner.planner; | ||
|
||
import com.google.common.base.Preconditions; | ||
import ec.util.MersenneTwisterFast; | ||
import uk.ac.ox.oxfish.fisher.Fisher; | ||
import uk.ac.ox.oxfish.fisher.purseseiner.strategies.fields.LocationValues; | ||
import uk.ac.ox.oxfish.geography.NauticalMap; | ||
import uk.ac.ox.oxfish.geography.SeaTile; | ||
|
||
/** | ||
* this object exists to generate a new deployment action (probably to add to a plan) | ||
|
@@ -17,25 +34,28 @@ public class DeploymentPlannedActionGenerator | |
private final double delayInHoursAfterADeployment; | ||
|
||
public DeploymentPlannedActionGenerator( | ||
final Fisher fisher, | ||
final LocationValues originalLocationValues, | ||
final NauticalMap map, | ||
final MersenneTwisterFast random | ||
) { | ||
this(originalLocationValues, map, random, 0); | ||
this(fisher, originalLocationValues, map, random, 0); | ||
} | ||
|
||
DeploymentPlannedActionGenerator( | ||
final Fisher fisher, | ||
final LocationValues originalLocationValues, | ||
final NauticalMap map, | ||
final MersenneTwisterFast random, | ||
final double delayInHoursAfterADeployment | ||
) { | ||
super(originalLocationValues, map, random); | ||
super(fisher, originalLocationValues, map, random); | ||
this.delayInHoursAfterADeployment = delayInHoursAfterADeployment; | ||
|
||
} | ||
|
||
public PlannedAction.Deploy drawNewPlannedAction() { | ||
@Override | ||
protected PlannedAction.Deploy locationToPlannedAction(final SeaTile location) { | ||
Preconditions.checkState(isReady(), "Did not start the deploy generator yet!"); | ||
return new PlannedAction.Deploy( | ||
drawNewLocation(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
/* | ||
* POSEIDON, an agent-based model of fisheries | ||
* Copyright (c) 2024-2024 CoHESyS Lab [email protected] | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package uk.ac.ox.oxfish.fisher.purseseiner.planner; | ||
|
||
import ec.util.MersenneTwisterFast; | ||
import uk.ac.ox.oxfish.fisher.Fisher; | ||
import uk.ac.ox.oxfish.fisher.purseseiner.strategies.fields.LocationValues; | ||
import uk.ac.ox.oxfish.geography.NauticalMap; | ||
import uk.ac.ox.oxfish.geography.SeaTile; | ||
|
||
public class FadStealingPlannedActionGenerator extends | ||
DrawFromLocationValuePlannedActionGenerator<PlannedAction.OpportunisticFadSet> { | ||
|
@@ -22,6 +39,7 @@ public class FadStealingPlannedActionGenerator extends | |
private final double probabilityOfFindingOtherFads; | ||
|
||
FadStealingPlannedActionGenerator( | ||
final Fisher fisher, | ||
final LocationValues originalLocationValues, | ||
final NauticalMap map, | ||
final MersenneTwisterFast random, | ||
|
@@ -30,15 +48,15 @@ public class FadStealingPlannedActionGenerator extends | |
final double minimumFadValueToSteal, | ||
final double probabilityOfFindingOtherFads | ||
) { | ||
super(originalLocationValues, map, random); | ||
super(fisher, originalLocationValues, map, random); | ||
this.hoursItTakesToSet = hoursItTakesToSet; | ||
this.hoursWastedIfNoFadAround = hoursWastedIfNoFadAround; | ||
this.minimumFadValueToSteal = minimumFadValueToSteal; | ||
this.probabilityOfFindingOtherFads = probabilityOfFindingOtherFads; | ||
} | ||
|
||
@Override | ||
public PlannedAction.OpportunisticFadSet drawNewPlannedAction() { | ||
protected PlannedAction.OpportunisticFadSet locationToPlannedAction(final SeaTile location) { | ||
return new PlannedAction.OpportunisticFadSet( | ||
drawNewLocation(), | ||
hoursItTakesToSet, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.