This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from 2nd-Semester-Project/main
main to userinterface
- Loading branch information
Showing
6 changed files
with
127 additions
and
3 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,10 +1,67 @@ | ||
using System.Security.Cryptography; | ||
|
||
namespace HeatOptimiser | ||
{ | ||
public class Schedule | ||
{ | ||
public DateTime startDate; | ||
public DateTime endDate; | ||
public List<ScheduleHour> schedule; | ||
public Schedule(DateTime start, DateTime end) | ||
{ | ||
startDate = start; | ||
endDate = end; | ||
schedule = []; | ||
} | ||
public void AddHour(DateTime? dateTime, List<ProductionAsset> assets, List<double> demands) | ||
{ | ||
schedule.Add(new ScheduleHour | ||
{ | ||
Hour = dateTime, | ||
Assets = assets, | ||
Demands = demands | ||
}); | ||
} | ||
} | ||
public class ScheduleHour | ||
{ | ||
public DateTime? Hour { get; set; } | ||
public List<ProductionAsset>? Assets { get; set; } | ||
public List<double>? Demands { get; set; } | ||
} | ||
public class Optimiser: IOptimiserModule | ||
{ | ||
private ISourceDataManager sd; | ||
private IAssetManager am; | ||
public Optimiser(ISourceDataManager sourceDataManager, IAssetManager assetManager) | ||
{ | ||
throw new System.NotImplementedException(); | ||
sd = sourceDataManager; | ||
am = assetManager; | ||
} | ||
|
||
public Schedule Optimise(DateTime startDate, DateTime endDate) | ||
{ | ||
SourceData data = new(); | ||
Schedule schedule = new(startDate, endDate); | ||
ProductionAsset gasBoiler = am.SearchUnits("GB")[0]; | ||
ProductionAsset oilBoiler = am.SearchUnits("OB")[0]; | ||
|
||
foreach (SourceDataPoint hour in sd.GetDataInRange(data, startDate, endDate)) | ||
{ | ||
if (hour.HeatDemand <= gasBoiler.Heat) | ||
{ | ||
double gasDemand = (double)hour.HeatDemand; | ||
schedule.AddHour(hour.TimeFrom, [gasBoiler], [gasDemand]); | ||
} | ||
else | ||
{ | ||
double gasCapacity = (double)gasBoiler.Heat; | ||
Check warning on line 58 in HeatOptimiser/Classes/Optimiser.cs GitHub Actions / build
|
||
double hourDemand = (double)hour.HeatDemand; | ||
Check warning on line 59 in HeatOptimiser/Classes/Optimiser.cs GitHub Actions / build
|
||
double oilDemand = hourDemand - gasCapacity; | ||
schedule.AddHour(hour.TimeFrom, [gasBoiler, oilBoiler], [gasCapacity, oilDemand]); | ||
} | ||
} | ||
return schedule; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"ID":"214839e8-f97d-4012-b50c-eb6f5f96856e","Name":"GB","Image":"none","Heat":5,"Electricity":0,"Energy":1.1,"Cost":500,"CarbonDioxide":215},{"ID":"23962281-442d-4c78-975e-a2c8777c304c","Name":"OB","Image":"none","Heat":4,"Electricity":0,"Energy":1.2,"Cost":700,"CarbonDioxide":265}] |
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