Skip to content

Comments

The FRBC planner #5

Open
VladIftime wants to merge 34 commits intomainfrom
feat/frbc-planner
Open

The FRBC planner #5
VladIftime wants to merge 34 commits intomainfrom
feat/frbc-planner

Conversation

@VladIftime
Copy link

This is a big PR. So, I suggest a collaborative review.

Flix6x and others added 6 commits January 20, 2025 14:08
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
@VladIftime VladIftime requested a review from jorritn January 31, 2025 19:19
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Seems to me this should work for a first version. There are some important differences with the original implementation. Two that quickly occur to me are: you allow None values is the profile list, and when checking for compatibility you only look at the time step duration and not the start time. This gives more flexibility but also enlarges the chance for bugs. Just something to consider.

if self.cost_improvement_value is None:
self.cost_improvement_value = self.get_cost(
self.old_plan, self.global_diff_target
) - self.get_cost(self.proposed_plan, self.global_diff_target)

This comment was marked as resolved.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it is. Sorry for bringing it up.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ok to me

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Price target not yet implemented but I guess that's deliberately?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a suggestion: abstract base classes can be used here.

Copy link
Collaborator

@jorritn jorritn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Most of the porting has been done. After porting S2FrbcDeviceStateWrapper and the ProfileMetadata (or something equivalent), you should be good to run a test on find_best_plan(). The DevicePlan class doesn't have to be ported for that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a duplicate with s2-frbc_device_planner. This can be removed, also because the device_controller is a different component in the architecture.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not extend the DevicePlanner class?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from that. Looks very good!

return self.latest_plan.get_energy()

def accept_proposal(self, accepted_proposal):
if accepted_proposal.get_origin() != self:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

origin needs to be added to the proposal class

if self.cost_improvement_value is None:
self.cost_improvement_value = self.get_cost(
self.old_plan, self.global_diff_target
) - self.get_cost(self.proposed_plan, self.global_diff_target)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it is. Sorry for bringing it up.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need some extra time to dive thoroughly into this but it looks good at first sight.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other classes had type hints. Would be good to add it here too.

Copy link
Collaborator

@jorritn jorritn Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this one later

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If guess this needs some extension later. If I understand it correct, the storageStatus should be included, for example.

for frbc_state in final_states:
frbc_state.generate_next_timestep_states(next_timestep)
end_state = self.find_best_end_state(
last_timestep.get_final_states_within_fill_level_target()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this include the emergency state? If yes, then it's fine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! It does 👍

S2FrbcDeviceStateWrapper.get_leakage_rate(self.timestep, self.fill_level)
* seconds
)
self.fill_level += self.timestep.get_forecasted_usage()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% sure whether this should be a plus or a minus. The original implementation has plus as well but intuitively I would think it should be a minus.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intuition was right: the protocol spec says: A positive value indicates that the fill level will decrease due to usage. https://github.com/flexiblepower/s2-ws-json/blob/b831b6f1f19f824f32269ecd6ac6a6e250e7af80/s2-asyncapi/s2-cem.yaml#L599C131-L599C205

Copy link
Collaborator

@jorritn jorritn Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In response to your TODO: conceptually is the same as the FRBCUsageForecast. The utility function from_storage_usage_profile converts it from an S2 data object into an array.

…a couple of wrappers

Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
@Flix6x Flix6x mentioned this pull request Feb 18, 2025
7 tasks
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
…rrors

Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
VladIftime and others added 12 commits March 14, 2025 11:19
… a target as input

Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
… added

Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
Signed-off-by: Vlad Iftime <vladiftime60@gmail.com>
This reverts commit f0e31b4.
* refactor: collect parameters

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: get rid of UUID actuator_id (prefer str instead)

Signed-off-by: F.N. Claessen <felix@seita.nl>

* delete: remove empty results file

Signed-off-by: F.N. Claessen <felix@seita.nl>

* docs: add instructions for profiling

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: get rid of UUID operation_mode_is (prefer str instead)

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants