Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Zero_engine.alpx
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,26 @@ LARGE_CONNECTION (grootverbruik, > 3x80)
<Name><![CDATA[GROUND_WATER]]></Name>
</Option>
</OptionList>
<OptionList>
<Id>1782815749074</Id>
<Name><![CDATA[OL_ForecastStatus]]></Name>
<Option>
<Id>1782815757572</Id>
<Name><![CDATA[PERFECT_FORECAST]]></Name>
</Option>
<Option>
<Id>1782815764204</Id>
<Name><![CDATA[ESTIMATED_FORECAST]]></Name>
</Option>
<Option>
<Id>1782815769499</Id>
<Name><![CDATA[NOT_FORECASTABLE]]></Name>
</Option>
<Option>
<Id>1782815773730</Id>
<Name><![CDATA[NO_ASSETS]]></Name>
</Option>
</OptionList>
</OptionLists>
<Folders>
<Folder>
Expand Down Expand Up @@ -2271,6 +2291,11 @@ LARGE_CONNECTION (grootverbruik, > 3x80)
<Name><![CDATA[DataSetConstructor]]></Name>
<Folder>1764938574089</Folder>
</JavaClass>
<JavaClass>
<Id>1782811550548</Id>
<Name><![CDATA[J_AssetTypeForecast]]></Name>
<Folder>1752680962144</Folder>
</JavaClass>
</JavaClasses>
<RequiredLibraryReference>
<LibraryName>com.anylogic.libraries.modules.markup_descriptors</LibraryName>
Expand Down
4 changes: 3 additions & 1 deletion _alp/Agents/EnergyModel/AOC.EnergyModel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ import com.querydsl.core.types.dsl.TimeExpression;
//import zero_engine.J_EAStorageElectric;
//import zero_engine.J_EAConsumption;

import com.anylogic.cloud.util.DateUtils;]]></Import>
import com.anylogic.cloud.util.DateUtils;

import zero_engine.J_ActivityTrackerTrips.TripRecord;]]></Import>
<Implements>I_EnergyData</Implements>
<Generic>false</Generic>
<GenericParameter>
Expand Down
117 changes: 117 additions & 0 deletions _alp/Agents/EnergyModel/Levels/Level.level.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1419,4 +1419,121 @@ energyDataViewer.viewArea.navigateTo();</ActionCode>
<Dy>0</Dy>
<Dz>0</Dz>
</Line>
<Control Type="Button">
<EmbeddedIcon>false</EmbeddedIcon>
<Id>1782465008753</Id>
<Name><![CDATA[button]]></Name>
<X>900</X>
<Y>-320</Y>
<Label>
<X>0</X>
<Y>-10</Y>
</Label>
<PublicFlag>true</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>false</ShowLabel>
<DrawMode>SHAPE_DRAW_2D3D</DrawMode>
<BasicProperties Width="100" Height="30">
<EmbeddedIcon>false</EmbeddedIcon>
<TextColor>-16777216</TextColor>
<Enabled>true</Enabled>
<ActionCode>traceln("index of 1 jan: %s", p_timeParameters.getDayOfWeek1jan());
traceln("day of 1 jan: %s", p_timeParameters.getDayFromDayIndex(p_timeParameters.getDayOfWeek1jan()));
traceln("p_timeParameters.getDayOfWeek1jan(): %s", p_timeParameters.getDayOfWeek1jan());
traceln("p_timeParameters.getWeekIndex(12): %s", p_timeParameters.getWeekIndex(12));
traceln("p_timeParameters.getWeekIndex(36): %s", p_timeParameters.getWeekIndex(36));
traceln("p_timeParameters.getWeekIndex(200): %s", p_timeParameters.getWeekIndex(200));
traceln("p_timeParameters.getWeekStart_h(0): %s", p_timeParameters.getWeekStart_h(0));
traceln("p_timeParameters.getWeekStart_h(1): %s", p_timeParameters.getWeekStart_h(1));
traceln("p_timeParameters.getWeekStart_h(2): %s", p_timeParameters.getWeekStart_h(2));</ActionCode>
</BasicProperties>
<ExtendedProperties>
<Font Name="Dialog" Size="11" Style="0"/>
<LabelText>Date</LabelText>
</ExtendedProperties>
</Control>
<Control Type="Button">
<EmbeddedIcon>false</EmbeddedIcon>
<Id>1782475157232</Id>
<Name><![CDATA[button1]]></Name>
<X>1040</X>
<Y>-320</Y>
<Label>
<X>0</X>
<Y>-10</Y>
</Label>
<PublicFlag>true</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>false</ShowLabel>
<DrawMode>SHAPE_DRAW_2D3D</DrawMode>
<BasicProperties Width="100" Height="30">
<EmbeddedIcon>false</EmbeddedIcon>
<TextColor>-16777216</TextColor>
<Enabled>true</Enabled>
<ActionCode>//GridConnection GC = findFirst(c_gridConnections, gc -&gt; gc.c_tripTrackers.size() &gt; 0);
GridConnection GC = findFirst(c_gridConnections, gc -&gt; gc.p_gridConnectionID.equals("addressuid.school"));
J_ActivityTrackerTrips tt = GC.c_tripTrackers.get(0);

double startTime_h = 0;
double endTime_h = 24+168;

List&lt;TripRecord&gt; trips = tt.getTripsInRange(startTime_h, endTime_h);

traceln(tt);

for (TripRecord trip : trips) {
traceln("startTime: %s", trip.startTime_h());
traceln("endTime: %s", trip.endTime_h());
traceln("distance: %s", trip.distance_km());
}</ActionCode>
</BasicProperties>
<ExtendedProperties>
<Font Name="Dialog" Size="11" Style="0"/>
<LabelText>Trips</LabelText>
</ExtendedProperties>
</Control>
<Control Type="Button">
<EmbeddedIcon>false</EmbeddedIcon>
<Id>1782826903548</Id>
<Name><![CDATA[button2]]></Name>
<X>1180</X>
<Y>-320</Y>
<Label>
<X>0</X>
<Y>-10</Y>
</Label>
<PublicFlag>true</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>false</ShowLabel>
<DrawMode>SHAPE_DRAW_2D3D</DrawMode>
<BasicProperties Width="100" Height="30">
<EmbeddedIcon>false</EmbeddedIcon>
<TextColor>-16777216</TextColor>
<Enabled>true</Enabled>
<ActionCode>//GridConnection GC = findFirst(c_gridConnections, gc -&gt; gc.c_tripTrackers.size() &gt; 0);
GridConnection GC = findFirst(c_gridConnections, gc -&gt; gc.p_gridConnectionID.equals("addressuid.school"));

double timeOfIntervalStart_h = 0;
double timeOfIntervalEnd_h = 48;

Map&lt;Class&lt; ? extends I_AssetManagement&gt;, J_AssetTypeForecast&gt; map = GC.f_getForecast(timeOfIntervalStart_h, timeOfIntervalEnd_h, p_timeParameters);

J_AssetTypeForecast chargingForecast = map.get(I_ChargingManagement.class);

traceln("chargingForecast: %s", chargingForecast);

Double[] load = chargingForecast.load_kW().get(OL_EnergyCarriers.ELECTRICITY);

traceln("load: ");
for (int i = 0; i &lt; timeOfIntervalEnd_h / p_timeParameters.getTimeStep_h(); i++) {
double t = timeOfIntervalStart_h + i * p_timeParameters.getTimeStep_h();
traceln("time t: %s, load: %s kW", t, load[i]);
}
</ActionCode>
</BasicProperties>
<ExtendedProperties>
<Font Name="Dialog" Size="11" Style="0"/>
<LabelText>Forecaster</LabelText>
</ExtendedProperties>
</Control>
</Presentation>
11 changes: 11 additions & 0 deletions _alp/Agents/GridConnection/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1242,3 +1242,14 @@ else if (heatingAsset instanceof J_EAConversionHeatPump heatPump) {
return nettoBalance_kW;
/*ALCODEEND*/}

Map<Class< ? extends I_AssetManagement>, J_AssetTypeForecast> f_getForecast(double timeOfIntervalStart_h,double timeOfIntervalEnd_h,J_TimeParameters timeParameters)
{/*ALCODESTART::1782459765981*/
if (p_energyManagement != null) {
return p_energyManagement.getFlexAssetForecast(timeOfIntervalStart_h, timeOfIntervalEnd_h);
}

else {
return new HashMap<Class<? extends I_AssetManagement>, J_AssetTypeForecast>();
}
/*ALCODEEND*/}

28 changes: 28 additions & 0 deletions _alp/Agents/GridConnection/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1210,4 +1210,32 @@
</Parameter>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="public" StaticFunction="false">
<ReturnModificator>RETURNS_VALUE</ReturnModificator>
<ReturnType>Map&lt;Class&lt; ? extends I_AssetManagement&gt;, J_AssetTypeForecast&gt;</ReturnType>
<Id>1782459765981</Id>
<Name><![CDATA[f_getForecast]]></Name>
<X>1490</X>
<Y>480</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Parameter>
<Name><![CDATA[timeOfIntervalStart_h]]></Name>
<Type><![CDATA[double]]></Type>
</Parameter>
<Parameter>
<Name><![CDATA[timeOfIntervalEnd_h]]></Name>
<Type><![CDATA[double]]></Type>
</Parameter>
<Parameter>
<Name><![CDATA[timeParameters]]></Name>
<Type><![CDATA[J_TimeParameters]]></Type>
</Parameter>
<Body xmlns:al="http://anylogic.com"/>
</Function>
</Functions>
2 changes: 1 addition & 1 deletion _alp/Classes/Class.I_AssetManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public interface I_AssetManagement extends I_StoreStatesAndReset
{
//Get the AssetManagementInterface type (I_ChargingManagement.class, I_Heatingmanagement.class, etc.)
Class<? extends I_AssetManagement> getAssetManagementInterfaceType();

J_AssetTypeForecast getForecast(double timeOfIntervalStart_h, double timeOfIntervalEnd_h);
}
22 changes: 21 additions & 1 deletion _alp/Classes/Class.I_EnergyManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,28 @@ default <T> boolean isAssetManagementSupported(Class<T> assetManagementType) {
return getInternalAssetManagements().contains(assetManagementType) || getSupportedExternalAssetManagements().contains(assetManagementType);
}


default public Map<Class<? extends I_AssetManagement>, J_AssetTypeForecast> getFlexAssetForecast(double timeOfIntervalStart_h, double timeOfIntervalEnd_h) {
Map<Class<? extends I_AssetManagement>, J_AssetTypeForecast> forecasts = new HashMap<Class<? extends I_AssetManagement>, J_AssetTypeForecast>();
Map<Class<? extends I_AssetManagement>, I_AssetManagement> activeExternalManagements = this.getActiveExternalAssetManagements();
for (Class externalManagementClass : this.getSupportedExternalAssetManagements()) {
I_AssetManagement externalManagement = activeExternalManagements.get(externalManagementClass);
if (externalManagement != null) {
J_AssetTypeForecast forecast = externalManagement.getForecast(timeOfIntervalStart_h, timeOfIntervalEnd_h);
forecasts.put(externalManagementClass, forecast);
}
}
for (Class internalManagementClass : this.getInternalAssetManagements()) {
J_AssetTypeForecast forecast = forecastInternalAssetType(internalManagementClass, timeOfIntervalStart_h, timeOfIntervalEnd_h);
forecasts.put(internalManagementClass, forecast);
}
return forecasts;
}


default J_AssetTypeForecast forecastInternalAssetType(Class<? extends I_AssetManagement> type, double timeOfIntervalStart_h, double timeOfIntervalEnd_h) {
throw new RuntimeException("EMS declares " + type.getSimpleName() + " as an internal asset management but does not override forecastInternalAssetType() to handle it.");
}

////Checks
//Check configuration: Should be called whenever a management or asset has been removed/added/changed.
default public void checkConfiguration(List<J_EAFlex> flexAssetsGCList) {
Expand Down
Loading