Hello Dr. Lofberg,
I'm on my second project using YALMIP / Gurobi. The first one went very well, but I'm having difficulty with my current project, which is writing a MILP problem to determine the optimum sequence of spacecraft operating modes at every timestep. Currently a 100-minute simulation, approximately half an orbital period, one minute per time step.
I'm using for my decision variable
mode = binvar(J,K);
Where J is the total number of time steps and K is the total number of possible modes. It may be possible, at a given j value, for there to be multiple k's set to 1, that is, multiple modes active, but for now I'm constraining it so just one k be equal to 1.
My battery constraints are setup to track battery state at every minute, and I do it step-wise. So if the battery state is known for jj = 1, then for every jj from jj = 2 to 100, I use a loop...
% 2. Build batt_state_inst(jj), set it >= batt_min_charge
batt_state_inst(jj) = batt_state_inst(jj-1) + mode(jj,1)*safe_powerrate(jj) + mode(jj,2)*hires_powerrate(jj) + mode(jj,4)*downlink_powerrate(jj) ...
+ mode(jj,3)*imu_powerrate(jj) + mode(jj,5)*safe_nocharge(jj);
F = [F, batt_state_inst(jj) >= batt_min_charge];
etc.
So the instantaneous batter state is built at time step jj, as the previous state plus the mode variable for that time step, which would result in the battery charge being increased or decreased. I was hoping this would be a valid setup for YALMIP constraints, but I'm getting the error
Error using lmi/horzcat (line 21)
One of the constraints evaluates to a FALSE LOGICAL variable
Error in reducedscaleversion (line 77)
F = [F, batt_state_inst(jj)-batt_min_charge >= 0];
I've tried a few variations on the code but always get the same error.
Could it be that I need to use the implies command? How would I set that up for multiple mode variables (all mode(jj,:) for a given jj), each with its own power usage?
Or perhaps there is another issue I'm not seeing?
Many thanks,
Tom