Clear Filters
Clear Filters

Optimization problem _input dimension

3 views (last 30 days)
NN on 27 Apr 2021
Answered: Nipun on 15 May 2024
While giving inputs to optimisation problem, how to set matrix dimensions of inputs like solar , load etc .i have 25 x 2 matrix corresponding values to 24 hours of time, so can i use the same dimension while using optimprob function ?
Please advice
this doubt is in reference to matlab microgrid optimisation problem.

Answers (1)

Nipun on 15 May 2024
Hi NN,
I understand that you are trying to input matrices of dimensions 25x2, representing values corresponding to 24 hours, into an optimization problem using the optimprob function in MATLAB. To align your data with the optimization framework, especially if you are working with hourly data for a 24-hour period, you should first ensure that your matrix dimensions correctly represent the time series data you intend to model. Typically, for a 24-hour period, you would use a 24x2 matrix. If you have a 25x2 matrix, verify whether the extra row is due to an additional data point or if it is an error. Assuming you have corrected your matrix to 24x2, representing 24 hours, here is how you can proceed:
% Assuming solar and load are your 24x2 matrices, corrected if necessary
% Example setup for an optimization problem
optimProblem = optimproblem;
% Define the time series data as parameters in the problem
params = optimproblem('Parameters', struct('solar', solar, 'load', load));
% Define decision variables, constraints, and objectives based on your problem
% For example, if optimizing energy storage dispatch
energyStorage = optimvar('energyStorage', 24, 'LowerBound', 0, 'UpperBound', capacity);
% Add constraints (example: energy balance)
optimProblem.Constraints.EnergyBalance = energyStorage +,1) == params.load(:,1);
% Define an objective (example: minimize cost or maximize efficiency)
optimProblem.Objective = sum(energyStorage); % Simplified objective
% Solve the problem
sol = solve(optimProblem);
This code snippet is a simplified example to illustrate how you might structure your optimization problem given time series data. You will need to adjust the decision variables, constraints, and objective function to fit the specifics of your microgrid optimization problem.
Hope this helps.


Find more on MATLAB in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!