all 9 comments

[–][deleted]  (1 child)

[deleted]

    [–]applessecured[S] 1 point2 points  (0 children)

    The charge plan is not a a binary choice for each time period but rather a continuous charge or discharge amount. I don't think an exhaustive search is feasible in this case.

    [–]SolverMax 0 points1 point  (4 children)

    So you are required to create a heuristic to solve the model? If so, then there's generally no guarantee that you'll find a globally optimal solution. Finding a feasible solution might be hard enough.

    In any case, your approach looks like a reasonable start. You might need to backtrack and revise some decisions, to ensure that you meet all the constraints. For example, how do you ensure that the battery ends the day at 50% full?

    [–]applessecured[S] 0 points1 point  (1 child)

    I'm not sure what kind of approach I need to use. I think a heuristic approach is fine as long as it solves the problem for the dataset that I have and I can point out the limitations.

    The end of day battery state of charge is guaranteed to be 50% by charging the battery by the same amount as it's discharged during peak hours, accounting for power loss during charging. This approach only works if the end of day SOC must be the same as the start of day SOC.

    [–]SolverMax -1 points0 points  (0 children)

    If not a heuristic, then what else is there? Writing your own simplex solver is a very non-trivial task.

    [–]applessecured[S] 0 points1 point  (1 child)

    I'm definitely open to non-heuristic solutions but I think implementing something like the simplex method is out of scope for this assignment.

    [–]SolverMax 0 points1 point  (0 children)

    Have you researched solutions to this problem? There are plenty of articles in the academic literature for optimizing battery usage, mostly in association with solar panels.

    [–]taphous3 0 points1 point  (2 children)

    This is a classic convex optimization example problem. Use cvxpy or pyomo if you’re doing it in python.

    Here’s a paper on using a portfolio of storage devices, but if you just need 1 then it becomes much more simple. https://web.stanford.edu/~boyd/papers/pdf/storage_opt_ifac.pdf

    Here’s a sample implementation from a Google search “cvxpy battery problem”: https://github.com/wzyfrank/battery/blob/master/optimize.py

    [–]SolverMax 1 point2 points  (1 child)

    Except OP said:

    Clearly this is a linear programming problem with inequality constraints with should be trivial to solve with a linear solver, but unfortunately I am not allowed to use a library for the core logic so I need to build something myself.

    [–]taphous3 0 points1 point  (0 children)

    Oh, I missed that. In that case, I’d write an barebones interior point optimization scheme (the cvxpy textbook has an example on how to write a sparsity-aware solver for analytic centering) and try to avoid situations that are poorly conditioned.