@mcg @Mark_L_Stone

I tried to simplify the problem with 24 steps

clc

clear all

tic

filename = ‘weatherdatafile.CSV’;

delimiter = ‘,’;

startRow = 3;

formatSpec = ‘%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%f%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%[^\n\r]’;

fileID = fopen(filename,‘r’);

dataArray = textscan(fileID, formatSpec, ‘Delimiter’, delimiter, ‘EmptyValue’ ,NaN,‘HeaderLines’ ,startRow-1, ‘ReturnOnError’, false);

fclose(fileID);

Tamb = [dataArray{1:end-1}];

clearvars filename delimiter startRow formatSpec fileID dataArray ans;

%% Import data from spreadsheet

price = xlsread(‘price.xlsx’,‘Sheet1’);

%% Solve optimization

n=24;

P=zeros(n);

Q=-100.5*(1-exp(-15/434));Q1=exp(-15/434);Q2=(1-exp(-15/434)); % Check 100.5 value for C/W

Price= 100.*price(1:24);*

P_ac=5;

To=Tamb(1:24); % Temp outside

Tmin=71;Tmax=75;Tint=[74;73;72];

cvx_begin

cvx_solver gurobi

variables T1(n+1) T2(n+1) T3(n+1) P(n);

variable W1(n) integer;

variable W2(n) integer;

variable W3(n) integer;

minimize PriceP

```
T1(1)==Tint(1);
T2(1)==Tint(2);
T3(1)==Tint(3);
```

for i=2:25;

```
T1(i)==To(i-1)*Q2+W1(i-1)*Q+T1(i-1)*Q1;
T2(i)==To(i-1)*Q2+W2(i-1)*Q+T2(i-1)*Q1;
T3(i)==To(i-1)*Q2+W3(i-1)*Q+T3(i-1)*Q1;
```

end

```
Tmin<=T1<=Tmax;
Tmin<=T2<=Tmax;
Tmin<=T3<=Tmax;
P==[W1]*P_ac+[W2]*P_ac+[W3]*P_ac;
0<=W1<=1;
0<=W2<=1;
0<=W3<=1;
```

cvx_end

toc

## The output come to

Calling Gurobi 6.00: 366 variables, 294 equality constraints

Gurobi optimizer, licensed to CVX for CVX

Optimize a model with 294 rows, 366 columns and 720 nonzeros

Coefficient statistics:

Matrix range [9e-01, 3e+00]

Objective range [7e+01, 7e+01]

Bounds range [0e+00, 0e+00]

RHS range [8e-02, 7e+00]

Presolve removed 6 rows and 261 columns

Presolve time: 0.00s

Explored 0 nodes (0 simplex iterations) in 0.00 seconds

Thread count was 1 (of 8 available processors)

## Model is infeasible or unbounded

Best objective -, best bound -, gap -

Status: Failed

Optimal value (cvx_optval): NaN