I am trying to solver the Unit Commitment problem (MIQP problem) by modelling the problem in CVXPY and using the CPLEX solver. I have been successful in getting everything to work with CVXPY using CPLEX. However, this was for a small system. Now I would like to do the same with a much larger system.
Side Note: I have successfully solved the MIQP problem in MATLAB using CPLEX. For larger system in MATLAB, I have used an initial solution from a MILP formulation of the problem and limited the CPLEX solver time using the "timelimit" parameter. This has successfully given me optimal solution in a short amount of time.
Now when I try to do the same with CVXPY and CPLEX, the CPLEX solver fails for the larger system. Also for the smaller system, I dont notice any difference in time to solve the problem. I have noted this based on the "solver.stats.solve_time" value. Therefore, I am unsure of whether the initial solution is getting used or neglected. This is some sample code for what I have done. These are my optimization variables:
power = cp.Variable((nUnits, nHours))
isOn = cp.Variable((nUnits, nHours), integer=True)
startup = cp.Variable((nUnits, nHours), integer=True)
I then have the section where I create my objective and constraints. Then I read in the initial solution from Excel and make the necessary adjustments to get it to look like the solution:
initial_power_soln_df = pd.read_excel(r'C:\Users\micah\Downloads\OneDrive-2020-04-17\init.xlsx', sheet_name='Sheet1', header=None)
initial_isOn_soln_df = pd.read_excel(r'C:\Users\micah\Downloads\OneDrive-2020-04-17\init.xlsx', sheet_name='Sheet2', header=None)
initial_startup_soln_df = pd.read_excel(r'C:\Users\micah\Downloads\OneDrive-2020-04-17\init.xlsx', sheet_name='Sheet3', header=None)
power.value = initial_power_soln_df.to_numpy().T
isOn.value = initial_isOn_soln_df.to_numpy().T
startup.value = initial_startup_soln_df.to_numpy().T
Finally, I create my problem and set up the solver:
problem = cp.Problem(cp.Minimize(cost), constr)
problem.solve(solver=cp.CPLEX, cplex_params={"timelimit": 300})
Not sure if this is the proper way to do this. Also NB. the initial solution comes from a MILP formulation and the optimization variables will be different from that of the MIQP formulation. So I cant just take the solution from the MILP and plug it in to the MIQP formulation. I first need to process the results.