From 628800fe385fcb8d86a1b8c27f892a7f2e818dd7 Mon Sep 17 00:00:00 2001 From: Luc-Sol Date: Thu, 4 Sep 2025 11:05:16 +0200 Subject: [PATCH 1/5] updating list of energycarriers when deserialising --- _alp/Agents/EnergyCoop/Code/Functions.java | 7 +++++++ _alp/Agents/EnergyModel/Code/Functions.java | 15 +++++++++++++-- _alp/Agents/EnergyModel/Variables.xml | 3 +++ _alp/Agents/GridConnection/Code/Functions.java | 8 ++++++++ _alp/Classes/Class.J_ValueMap.java | 2 +- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/_alp/Agents/EnergyCoop/Code/Functions.java b/_alp/Agents/EnergyCoop/Code/Functions.java index e0c3ebbf..7ba53f32 100644 --- a/_alp/Agents/EnergyCoop/Code/Functions.java +++ b/_alp/Agents/EnergyCoop/Code/Functions.java @@ -1449,6 +1449,13 @@ HashSet f_getAllChildCustomerGridConnections_recursion(HashSet p.updateValue(t_h)); +v_currentAmbientTemperature_degC = pp_ambientTemperature_degC.getCurrentValue(); v_currentWindPowerNormalized_r = pp_windProduction_fr.getCurrentValue(); v_currentSolarPowerNormalized_r = pp_PVProduction35DegSouth_fr.getCurrentValue(); //v_currentCookingDemand_fr = tf_cooking_demand(t_h); @@ -1048,8 +1048,19 @@ EnergyCoop f_addProductionEnergyCarrier(OL_EnergyCarriers EC) double f_startAfterDeserialisation() {/*ALCODESTART::1753963201170*/ - v_liveData = new J_LiveData(this); +v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY); +v_liveData.activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY); +v_liveData.activeConsumptionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY); + +//v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY, OL_EnergyCarriers.HEAT, OL_EnergyCarriers.METHANE, OL_EnergyCarriers.DIESEL); +//v_liveData.activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY, OL_EnergyCarriers.HEAT); +//v_liveData.activeConsumptionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY, OL_EnergyCarriers.HEAT, OL_EnergyCarriers.METHANE, OL_EnergyCarriers.DIESEL); +for (J_EA j_ea : c_energyAssets) { + v_liveData.activeProductionEnergyCarriers.addAll(j_ea.activeProductionEnergyCarriers); + v_liveData.activeConsumptionEnergyCarriers.addAll(j_ea.activeConsumptionEnergyCarriers); +} + v_liveConnectionMetaData = new J_ConnectionMetaData(this); v_liveAssetsMetaData = new J_AssetsMetaData(this); v_liveData.connectionMetaData = v_liveConnectionMetaData; diff --git a/_alp/Agents/EnergyModel/Variables.xml b/_alp/Agents/EnergyModel/Variables.xml index 3651ee38..18b482d5 100644 --- a/_alp/Agents/EnergyModel/Variables.xml +++ b/_alp/Agents/EnergyModel/Variables.xml @@ -1111,6 +1111,9 @@ AccessType="public" StaticVariable="false"> + + + diff --git a/_alp/Agents/GridConnection/Code/Functions.java b/_alp/Agents/GridConnection/Code/Functions.java index c1816ac3..40499475 100644 --- a/_alp/Agents/GridConnection/Code/Functions.java +++ b/_alp/Agents/GridConnection/Code/Functions.java @@ -1233,11 +1233,19 @@ else if (flowsMap.get(EC) > 0){ double f_startAfterDeserialisation() {/*ALCODESTART::1753348699140*/ v_liveData = new J_LiveData(this); +v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY); +v_liveData.activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY); +v_liveData.activeConsumptionEnergyCarriers= EnumSet.of(OL_EnergyCarriers.ELECTRICITY); +for (J_EA j_ea : c_energyAssets) { + v_liveData.activeProductionEnergyCarriers.addAll(j_ea.activeProductionEnergyCarriers); + v_liveData.activeConsumptionEnergyCarriers.addAll(j_ea.activeConsumptionEnergyCarriers); +} //v_liveConnectionMetaData = new J_ConnectionMetaData(this); //v_liveAssetsMetaData = new J_AssetsMetaData(this); v_liveData.connectionMetaData = v_liveConnectionMetaData; v_liveData.assetsMetaData = v_liveAssetsMetaData; + fm_currentProductionFlows_kW = new J_FlowsMap(); fm_currentConsumptionFlows_kW = new J_FlowsMap(); fm_currentBalanceFlows_kW = new J_FlowsMap(); diff --git a/_alp/Classes/Class.J_ValueMap.java b/_alp/Classes/Class.J_ValueMap.java index a5735c3e..03c2856c 100644 --- a/_alp/Classes/Class.J_ValueMap.java +++ b/_alp/Classes/Class.J_ValueMap.java @@ -1,4 +1,4 @@ - /** +/** * J_ValueMap */ import zeroPackage.ZeroMath; From 02dd8a1524889673786a7337b8e2459e7678aaf1 Mon Sep 17 00:00:00 2001 From: Luc-Sol Date: Tue, 9 Sep 2025 09:28:44 +0200 Subject: [PATCH 2/5] Added p_uid to GC GCs now have a final String p_uid with a randomized UUID. Later we could possibly put the EANs in this field. --- _alp/Agents/EnergyCoop/Code/Functions.java | 19 +++-- _alp/Agents/EnergyCoop/Code/Functions.xml | 1 + _alp/Agents/EnergyModel/Code/Functions.java | 67 ++++++++++++--- _alp/Agents/EnergyModel/EmbeddedObjects.xml | 30 +++++++ .../AOC.GCDistrictHeating.xml | 3 + .../AOC.GCEnergyConversion.xml | 3 + .../AOC.GCEnergyProduction.xml | 3 + .../GCGridBattery/AOC.GCGridBattery.xml | 3 + _alp/Agents/GCHouse/AOC.GCHouse.xml | 3 + _alp/Agents/GCIndustry/AOC.GCIndustry.xml | 3 + .../GCNeighborhood/AOC.GCNeighborhood.xml | 3 + .../GCPublicCharger/AOC.GCPublicCharger.xml | 3 + _alp/Agents/GCUtility/AOC.GCUtility.xml | 3 + .../Code/AdditionalClassCode.java | 5 +- .../Agents/GridConnection/Code/Functions.java | 85 ++++++++++--------- _alp/Agents/GridConnection/Code/Functions.xml | 21 +++++ _alp/Agents/GridConnection/Variables.xml | 26 ++++++ 17 files changed, 225 insertions(+), 56 deletions(-) diff --git a/_alp/Agents/EnergyCoop/Code/Functions.java b/_alp/Agents/EnergyCoop/Code/Functions.java index 7ba53f32..18f62bb9 100644 --- a/_alp/Agents/EnergyCoop/Code/Functions.java +++ b/_alp/Agents/EnergyCoop/Code/Functions.java @@ -1452,19 +1452,26 @@ HashSet f_getAllChildCustomerGridConnections_recursion(HashSetdouble 1753348770752 + true 980 70 + + 1757330831065 + + true + 50 + 100 + + false + true + true + + + NONE + false + + 1757330831063 + TEXT_BOX + 0 + 100 + NO_DELIMETER + + + 1659962626903 From a2eceb6366f734d009a0e2b53a991bd87ca7225e Mon Sep 17 00:00:00 2001 From: Luc-Sol Date: Mon, 22 Sep 2025 10:11:49 +0200 Subject: [PATCH 3/5] @JsonTypeInfo and Date changes - Changed @JsonTypeInfo to use JsonTypeInfo.Id.CLASS, instead of JsonTypeInfo.Id.NAME. Now there is no need to list the subclasses as subtypes. - Added function f_getDate to EnergyModel. Models should use this instead of AnyLogic's date() function. - Bugfix: J_LiveData's method resetLiveDataSets off-by-one error --- _alp/Agents/EnergyModel/AOC.EnergyModel.xml | 3 ++- _alp/Agents/EnergyModel/Code/Functions.java | 16 +++++++++++++--- _alp/Agents/EnergyModel/Code/Functions.xml | 16 ++++++++++++++++ _alp/Agents/GIS_Object/AOC.GIS_Object.xml | 4 +++- .../Agents/GridConnection/AOC.GridConnection.xml | 4 +++- _alp/Classes/Class.ActorMixin.java | 5 ++++- _alp/Classes/Class.AgentMixin.java | 5 ++++- .../Class.I_AggregatorBatteryManagement.java | 4 +++- _alp/Classes/Class.I_BatteryManagement.java | 6 ++++-- _alp/Classes/Class.I_ChargingManagement.java | 6 ++++-- _alp/Classes/Class.I_HeatingManagement.java | 5 ++++- _alp/Classes/Class.J_Contract.java | 4 +++- _alp/Classes/Class.J_EA.java | 10 ++++++++-- _alp/Classes/Class.J_LiveData.java | 6 +++--- 14 files changed, 74 insertions(+), 20 deletions(-) diff --git a/_alp/Agents/EnergyModel/AOC.EnergyModel.xml b/_alp/Agents/EnergyModel/AOC.EnergyModel.xml index 77f9d991..74a45e5b 100644 --- a/_alp/Agents/EnergyModel/AOC.EnergyModel.xml +++ b/_alp/Agents/EnergyModel/AOC.EnergyModel.xml @@ -51,7 +51,8 @@ import com.anylogic.engine.markup.GISPoint; import com.querydsl.core.types.dsl.TimeExpression; //import zero_engine.J_EAStorageElectric; //import zero_engine.J_EAConsumption; -]]> + +import com.anylogic.cloud.util.DateUtils;]]> I_EnergyData f_getPausedGridConnectionsCollectionPointer() } /*ALCODEEND*/} +Date f_getDate() +{/*ALCODESTART::1758012535712*/ +Date startDate = getExperiment().getEngine().getStartDate(); +long startDateUnixTime_ms = startDate.getTime(); +long runtime_ms = (long) (v_timeStepsElapsed * p_timeStep_h * 60 * 60 * 1000); +Date date = new Date(); +date.setTime(startDateUnixTime_ms + runtime_ms); +return date; +/*ALCODEEND*/} + diff --git a/_alp/Agents/EnergyModel/Code/Functions.xml b/_alp/Agents/EnergyModel/Code/Functions.xml index a015d1ce..5bd07b60 100644 --- a/_alp/Agents/EnergyModel/Code/Functions.xml +++ b/_alp/Agents/EnergyModel/Code/Functions.xml @@ -698,4 +698,20 @@ true + + RETURNS_VALUE + Date + 1758012535712 + + 720 + 430 + + false + true + true + + diff --git a/_alp/Agents/GIS_Object/AOC.GIS_Object.xml b/_alp/Agents/GIS_Object/AOC.GIS_Object.xml index ec08a798..9e55691a 100644 --- a/_alp/Agents/GIS_Object/AOC.GIS_Object.xml +++ b/_alp/Agents/GIS_Object/AOC.GIS_Object.xml @@ -10,16 +10,18 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, + use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type" // 👈 this will be the field name in your JSON ) +/* @JsonSubTypes({ @JsonSubTypes.Type(value = GIS_Building.class, name = "GIS_Building"), @JsonSubTypes.Type(value = GIS_Parcel.class, name = "GIS_Parcel"), // Add other known subtypes here if needed }) +*/ @JsonIgnoreProperties({"va_building", "va_parcel", "_origin_VA","gisRegion", "p_defaultFillColor", "p_defaultLineColor", "p_defaultLineStyle"})]]> diff --git a/_alp/Agents/GridConnection/AOC.GridConnection.xml b/_alp/Agents/GridConnection/AOC.GridConnection.xml index 27a817ac..c8686986 100644 --- a/_alp/Agents/GridConnection/AOC.GridConnection.xml +++ b/_alp/Agents/GridConnection/AOC.GridConnection.xml @@ -30,10 +30,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonSubTypes; @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, + use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type" // 👈 this will be the field name in your JSON ) +/* @JsonSubTypes({ @JsonSubTypes.Type(value = GCDistrictHeating.class, name = "GCDistrictHeating"), @JsonSubTypes.Type(value = GCEnergyConversion.class, name = "GCEnergyConversion"), @@ -48,6 +49,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; // Add other known subtypes here if needed }) +*/ @JsonIgnoreProperties({"va_gridConnection","_origin_VA","_pl_powerFlows_autoUpdateEvent_xjal","_SOC_plot_autoUpdateEvent_xjal"}) @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "@id")]]> diff --git a/_alp/Classes/Class.ActorMixin.java b/_alp/Classes/Class.ActorMixin.java index fa798be2..bde6b49b 100644 --- a/_alp/Classes/Class.ActorMixin.java +++ b/_alp/Classes/Class.ActorMixin.java @@ -12,10 +12,11 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonSubTypes; @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, + use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type" // 👈 this will be the field name in your JSON ) +/* @JsonSubTypes({ @JsonSubTypes.Type(value = ConnectionOwner.class, name = "ConnectionOwner"), @JsonSubTypes.Type(value = EnergyCoop.class, name = "EnergyCoop"), @@ -32,6 +33,8 @@ // Add other known subtypes here if needed }) +*/ + public abstract class ActorMixin implements Serializable { /*@JsonIgnore diff --git a/_alp/Classes/Class.AgentMixin.java b/_alp/Classes/Class.AgentMixin.java index 91ce701e..477319cf 100644 --- a/_alp/Classes/Class.AgentMixin.java +++ b/_alp/Classes/Class.AgentMixin.java @@ -11,10 +11,11 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonSubTypes; @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, + use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type" // 👈 this will be the field name in your JSON ) +/* @JsonSubTypes({ // Needed because parentAgent in J_EA is of type Agent, and paused gridConnections are first serialized via their energy assets, leading to type ambigueity @JsonSubTypes.Type(value = Actor.class, name = "Actor"), @JsonSubTypes.Type(value = GridConnection.class, name = "GridConnection"), @@ -31,6 +32,8 @@ // Add other known subtypes here if needed }) +*/ + @JsonAutoDetect( fieldVisibility = Visibility.PUBLIC_ONLY, // ✅ only public fields are serialized getterVisibility = Visibility.NONE, diff --git a/_alp/Classes/Class.I_AggregatorBatteryManagement.java b/_alp/Classes/Class.I_AggregatorBatteryManagement.java index 081abbea..c90728fc 100644 --- a/_alp/Classes/Class.I_AggregatorBatteryManagement.java +++ b/_alp/Classes/Class.I_AggregatorBatteryManagement.java @@ -5,16 +5,18 @@ @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "@id") @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, + use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type" // 👈 this will be the field name in your JSON 👈 ) +/* @JsonSubTypes({ @JsonSubTypes.Type(value = J_AggregatorBatteryManagementOff.class, name = "J_AggregatorBatteryManagementOff"), @JsonSubTypes.Type(value = J_AggregatorBatteryManagementCollectiveSelfConsumption_batterySize.class, name = "J_AggregatorBatteryManagementCollectiveSelfConsumption_batterySize"), @JsonSubTypes.Type(value = J_AggregatorBatteryManagementCollectiveSelfConsumption_exportRate.class, name = "J_AggregatorBatteryManagementCollectiveSelfConsumption_exportRate"), @JsonSubTypes.Type(value = J_AggregatorBatteryManagementCollectiveSelfConsumption_exportRateGH.class, name = "J_AggregatorBatteryManagementCollectiveSelfConsumption_exportRateGH"), }) +*/ /** * I_AggregatorBatteryManagement diff --git a/_alp/Classes/Class.I_BatteryManagement.java b/_alp/Classes/Class.I_BatteryManagement.java index 5550c05f..6ad14183 100644 --- a/_alp/Classes/Class.I_BatteryManagement.java +++ b/_alp/Classes/Class.I_BatteryManagement.java @@ -5,10 +5,11 @@ @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "@id") @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, + use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type" // 👈 this will be the field name in your JSON ) +/* @JsonSubTypes({ @JsonSubTypes.Type(value = J_BatteryManagementOff.class, name = "J_BatteryManagementOff"), @JsonSubTypes.Type(value = J_BatteryManagementPeakShaving.class, name = "J_BatteryManagementPeakShaving"), @@ -18,7 +19,8 @@ @JsonSubTypes.Type(value = J_BatteryManagementSelfConsumptionGridNode.class, name = "J_BatteryManagementSelfConsumptionGridNode"), @JsonSubTypes.Type(value = J_BatteryManagementExternalSetpoint.class, name = "J_BatteryManagementExternalSetpoint"), }) - +*/ + // Add other known subtypes here if needed public interface I_BatteryManagement diff --git a/_alp/Classes/Class.I_ChargingManagement.java b/_alp/Classes/Class.I_ChargingManagement.java index d0a645d0..50f4f74b 100644 --- a/_alp/Classes/Class.I_ChargingManagement.java +++ b/_alp/Classes/Class.I_ChargingManagement.java @@ -6,17 +6,19 @@ @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "@id") @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, + use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type" // 👈 this will be the field name in your JSON ) +/* @JsonSubTypes({ @JsonSubTypes.Type(value = J_ChargingManagementLocalBalancing.class, name = "J_ChargingManagementLocalBalancing"), @JsonSubTypes.Type(value = J_ChargingManagementMaxAvailablePower.class, name = "J_ChargingManagementMaxAvailablePower"), @JsonSubTypes.Type(value = J_ChargingManagementPrice.class, name = "J_ChargingManagementPrice"), @JsonSubTypes.Type(value = J_ChargingManagementSimple.class, name = "J_ChargingManagementSimple"), }) - +*/ + public interface I_ChargingManagement { void manageCharging(); diff --git a/_alp/Classes/Class.I_HeatingManagement.java b/_alp/Classes/Class.I_HeatingManagement.java index 7ee6f197..2e8402e5 100644 --- a/_alp/Classes/Class.I_HeatingManagement.java +++ b/_alp/Classes/Class.I_HeatingManagement.java @@ -2,8 +2,11 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.ObjectIdGenerators; + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "@id") +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type") +/* @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, @@ -21,7 +24,7 @@ @JsonSubTypes.Type(value = J_HeatingManagementProfileWithPTBufferSimple.class, name = "J_HeatingManagementProfileWithPTBufferSimple"), @JsonSubTypes.Type(value = J_HeatingManagementSimple.class, name = "J_HeatingManagementSimple"), }) - +*/ public interface I_HeatingManagement { void manageHeating(); // Initiliaze throws an exception when the configuration of assets is not a valid combination diff --git a/_alp/Classes/Class.J_Contract.java b/_alp/Classes/Class.J_Contract.java index 06107d0a..5b7f2091 100644 --- a/_alp/Classes/Class.J_Contract.java +++ b/_alp/Classes/Class.J_Contract.java @@ -2,16 +2,18 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, + use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "type" // 👈 this will be the field name in your JSON ) +/* @JsonSubTypes({ @JsonSubTypes.Type(value = J_DeliveryContract.class, name = "J_DeliveryContract"), @JsonSubTypes.Type(value = J_ConnectionContract.class, name = "J_ConnectionContract"), @JsonSubTypes.Type(value = J_TransportContract.class, name = "J_TransportContract"), @JsonSubTypes.Type(value = J_TaxContract.class, name = "J_TaxContract"), }) +*/ public class J_Contract implements Serializable { diff --git a/_alp/Classes/Class.J_EA.java b/_alp/Classes/Class.J_EA.java index 142f5a82..8facd25f 100644 --- a/_alp/Classes/Class.J_EA.java +++ b/_alp/Classes/Class.J_EA.java @@ -20,7 +20,12 @@ setterVisibility = Visibility.NONE, creatorVisibility = Visibility.NONE ) - +@JsonTypeInfo( + use = JsonTypeInfo.Id.CLASS, + include = JsonTypeInfo.As.PROPERTY, + property = "type" + ) +/* @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, @@ -39,11 +44,12 @@ @JsonSubTypes.Type(value = J_EAConversionHeatPump.class, name = "J_EAConversionHeatPump"), @JsonSubTypes.Type(value = J_EAEV.class, name = "J_EAEV"), @JsonSubTypes.Type(value = J_EADieselVehicle.class, name = "J_EADieselVehicle"), + @JsonSubTypes.Type(value = J_EAHydrogenVehicle.class, name = "J_EAHydrogenVehicle"), @JsonSubTypes.Type(value = J_EAConversionHeatDeliverySet.class, name = "J_EAConversionHeatDeliverySet"), - // Add other known subtypes here if needed }) +*/ @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "@id") abstract public class J_EA implements Cloneable { diff --git a/_alp/Classes/Class.J_LiveData.java b/_alp/Classes/Class.J_LiveData.java index f0c5a7ab..8fd4c645 100644 --- a/_alp/Classes/Class.J_LiveData.java +++ b/_alp/Classes/Class.J_LiveData.java @@ -36,7 +36,7 @@ public J_LiveData(Agent parentAgent) { public void resetLiveDatasets(double startTime, double endTime, double timeStep_h) { for(OL_EnergyCarriers EC : activeConsumptionEnergyCarriers){ DataSet dsDemand = new DataSet( (int)(168 / timeStep_h) ); - for (double t = startTime; t <= endTime; t += timeStep_h) { + for (double t = startTime; t < endTime; t += timeStep_h) { dsDemand.add( t, 0); } dsm_liveDemand_kW.put( EC, dsDemand); @@ -44,7 +44,7 @@ public void resetLiveDatasets(double startTime, double endTime, double timeStep_ for(OL_EnergyCarriers EC : activeProductionEnergyCarriers){ DataSet dsSupply = new DataSet( (int)(168 / timeStep_h) ); - for (double t = startTime; t <= endTime; t += timeStep_h) { + for (double t = startTime; t < endTime; t += timeStep_h) { dsSupply.add( t, 0); } dsm_liveSupply_kW.put( EC, dsSupply); @@ -57,7 +57,7 @@ public void resetLiveDatasets(double startTime, double endTime, double timeStep_ } } - for (double t = startTime; t <= endTime; t += timeStep_h) { + for (double t = startTime; t < endTime; t += timeStep_h) { for (OL_AssetFlowCategories AC : assetsMetaData.activeAssetFlows) { dsm_liveAssetFlows_kW.get(AC).add(t, 0); From e31caaf9d75c0965f90e4051c80ddfa06c427462 Mon Sep 17 00:00:00 2001 From: Luc-Sol Date: Tue, 23 Sep 2025 09:01:47 +0200 Subject: [PATCH 4/5] changed memberGCs in EneryCoop to public changed the collection of memberGCs in EneryCoop to public so that it is serialized in the save files. --- _alp/Agents/EnergyCoop/Variables.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_alp/Agents/EnergyCoop/Variables.xml b/_alp/Agents/EnergyCoop/Variables.xml index 522dec8c..6f693474 100644 --- a/_alp/Agents/EnergyCoop/Variables.xml +++ b/_alp/Agents/EnergyCoop/Variables.xml @@ -2015,7 +2015,7 @@ false true true - + ArrayList GridConnection Object From 3202f21957bfe621d075e864c5b400a7ec45ebf2 Mon Sep 17 00:00:00 2001 From: Ate Hempenius Date: Tue, 23 Sep 2025 11:46:19 +0200 Subject: [PATCH 5/5] fixing the looping of simulation --- Zero_engine.alpx | 7 +- _alp/Agents/EnergyModel/Code/Functions.java | 33 +++++++--- _alp/Agents/EnergyModel/Code/Functions.xml | 66 ++++++++++++++----- .../Agents/EnergyModel/Levels/Level.level.xml | 65 ++++++++++++++++-- _alp/Classes/Class.J_LiveData.java | 27 +++++++- 5 files changed, 164 insertions(+), 34 deletions(-) diff --git a/Zero_engine.alpx b/Zero_engine.alpx index c3111ee5..b3a60fb7 100644 --- a/Zero_engine.alpx +++ b/Zero_engine.alpx @@ -1,8 +1,8 @@ + AnyLogicVersion="8.9.6.202509050523" + AlpVersion="8.9.6"> 1658477103134 @@ -1121,6 +1121,7 @@ 1.0 1.0 0.1 + DEFAULT 1658477089997 1920 @@ -1778,5 +1779,7 @@ e6625695-25a2-43d0-9056-1e9a1a594b1e 91990287-4edf-4e38-aa6c-66d0e906807b 2216cdd0-177c-5678-9e88-dd8b95312234 + 1737c8c6-b526-4dd8-589e-ee4e205b06f4 + 6a43bef6-8b70-4253-a828-82c3ab399655 diff --git a/_alp/Agents/EnergyModel/Code/Functions.java b/_alp/Agents/EnergyModel/Code/Functions.java index a62e9036..97f16fe2 100644 --- a/_alp/Agents/EnergyModel/Code/Functions.java +++ b/_alp/Agents/EnergyModel/Code/Functions.java @@ -470,16 +470,13 @@ double f_runTimestep() {/*ALCODESTART::1701162826549*/ -t_h = p_runStartTime_h + v_timeStepsElapsed * p_timeStep_h;// + v_hourOfYearStart);// % 8760; - -// Reduce startdate after one year, loop all dat -if(t_h-p_runStartTime_h!=0.0 && (t_h-p_runStartTime_h) % 8760 == 0.0) { - Date startDate = getExperiment().getEngine().getStartDate(); - startDate.setYear(startDate.getYear()-1); - getExperiment().getEngine().setStartDate(startDate); - traceln("Reduced anylogic date by one year, looping all data"); +if(t_h-p_runStartTime_h!=0.0 && (t_h-p_runStartTime_h) % (p_runEndTime_h - p_runStartTime_h) == 0.0) { + f_loopSimulation(); } +//Update t_h +t_h = p_runStartTime_h + v_timeStepsElapsed * p_timeStep_h; + // Update tijdreeksen in leesbare variabelen f_updateTimeseries(t_h); @@ -1223,3 +1220,23 @@ Date f_getDate() return date; /*ALCODEEND*/} +double f_loopSimulation() +{/*ALCODESTART::1758619562148*/ +v_timeStepsElapsed = 0; +f_clearAllLiveDatasets(); +traceln("The simulation has been looped."); +/*ALCODEEND*/} + +double f_clearAllLiveDatasets() +{/*ALCODESTART::1758619851984*/ +//Energy Model +v_liveData.clearLiveDatasets(); + +//Energy Coops +pop_energyCoops.forEach(EC -> EC.v_liveData.clearLiveDatasets()); + +//GridConnections +c_gridConnections.forEach(GC -> GC.v_liveData.clearLiveDatasets()); +c_pausedGridConnections.forEach(GC -> GC.v_liveData.clearLiveDatasets()); +/*ALCODEEND*/} + diff --git a/_alp/Agents/EnergyModel/Code/Functions.xml b/_alp/Agents/EnergyModel/Code/Functions.xml index 5bd07b60..e3d954d9 100644 --- a/_alp/Agents/EnergyModel/Code/Functions.xml +++ b/_alp/Agents/EnergyModel/Code/Functions.xml @@ -242,7 +242,7 @@ 1716890117265 1640 - 370 + 500