-
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.
remove AlgorithmFactories and some associate classes
the YAML-related code is still icky, but we have now fully moved to Java service-loader infrastructure!
- Loading branch information
1 parent
72c009c
commit 52a1cbf
Showing
11 changed files
with
194 additions
and
678 deletions.
There are no files selected for viewing
48 changes: 0 additions & 48 deletions
48
POSEIDON/src/main/java/uk/ac/ox/oxfish/biology/complicated/factory/MortalityFactories.java
This file was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
POSEIDON/src/main/java/uk/ac/ox/oxfish/geography/mapmakers/MapInitializers.java
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
POSEIDON/src/main/java/uk/ac/ox/oxfish/model/market/gas/GasPriceMakers.java
This file was deleted.
Oops, something went wrong.
81 changes: 0 additions & 81 deletions
81
POSEIDON/src/main/java/uk/ac/ox/oxfish/model/regs/factory/Regulations.java
This file was deleted.
Oops, something went wrong.
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,21 +1,19 @@ | ||
/* | ||
* POSEIDON, an agent-based model of fisheries | ||
* Copyright (C) 2017 CoHESyS Lab [email protected] | ||
* POSEIDON: an agent-based model of fisheries | ||
* Copyright (c) 2017-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/>. | ||
* 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.model.regs.factory; | ||
|
@@ -27,16 +25,12 @@ | |
import uk.ac.ox.poseidon.common.core.parameters.FixedDoubleParameter; | ||
|
||
/** | ||
* Creates a single mono-quota object and shares it every time it is called. If you modify the quota parameter here, it will | ||
* affect all the quotas that were created before as well | ||
* Created by carrknight on 6/14/15. | ||
* Creates a single mono-quota object and shares it every time it is called. If you modify the quota | ||
* parameter here, it will affect all the quotas that were created before as well Created by | ||
* carrknight on 6/14/15. | ||
*/ | ||
public class TACMonoFactory implements AlgorithmFactory<MonoQuotaRegulation> { | ||
/** | ||
* This provides a static singleton instance that will be used when building the list of constructors in the | ||
* {@link uk.ac.ox.oxfish.utility.AlgorithmFactories} class, so all the TACs are forced to remain connected. | ||
*/ | ||
private static final TACMonoFactory instance = new TACMonoFactory(); | ||
|
||
/** | ||
* for each model there is only one quota object being shared | ||
*/ | ||
|
@@ -49,10 +43,6 @@ public class TACMonoFactory implements AlgorithmFactory<MonoQuotaRegulation> { | |
*/ | ||
private DoubleParameter quota = new FixedDoubleParameter(500000); | ||
|
||
public static TACMonoFactory getInstance() { | ||
return instance; | ||
} | ||
|
||
/** | ||
* Creates a TAC and optionally the whole structure that keeps track of opportunity costs | ||
* | ||
|
@@ -63,27 +53,25 @@ public static TACMonoFactory getInstance() { | |
@SuppressWarnings("unchecked") | ||
public MonoQuotaRegulation apply(final FishState state) { | ||
|
||
|
||
final Double yearlyQuota = quota.applyAsDouble(state.random); | ||
final MonoQuotaRegulation quotaRegulation = | ||
modelQuota.presentKey( | ||
state.getUniqueID(), | ||
() -> new MonoQuotaRegulation(yearlyQuota) | ||
); | ||
|
||
//if it has not been consumed (probably because the model still has to start) then: | ||
// if it has not been consumed (probably because the model still has to start) then: | ||
if (quotaRegulation.getQuotaRemaining(0) > 0 && | ||
Math.abs(quotaRegulation.getQuotaRemaining(0) - quotaRegulation.getYearlyQuota()) < .1) | ||
quotaRegulation.setQuotaRemaining(0, yearlyQuota); | ||
|
||
//set yearly quota (notice that this will affect everyone) | ||
// set yearly quota (notice that this will affect everyone) | ||
quotaRegulation.setYearlyQuota(yearlyQuota); | ||
|
||
//don't let quota remaining be above yearly quota though | ||
// don't let quota remaining be above yearly quota though | ||
if (quotaRegulation.getQuotaRemaining(0) > quotaRegulation.getYearlyQuota()) | ||
quotaRegulation.setQuotaRemaining(0, yearlyQuota); | ||
|
||
|
||
return quotaRegulation; | ||
|
||
} | ||
|
@@ -92,11 +80,9 @@ public DoubleParameter getQuota() { | |
return quota; | ||
} | ||
|
||
|
||
public void setQuota(final DoubleParameter quota) { | ||
this.quota = quota; | ||
} | ||
|
||
|
||
} | ||
|
Oops, something went wrong.