Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-05-2019 01:30 AM
(495 views)

Hi guys,

I am having trouble to add the new constraints for this kind of problem. The work I am doing is managing the pump and valve running over the 24 hours from 8 am to 7 am the next day.

set<num> = {8,9,10,11,...7};

set PUMP = /Pump1 Pump2 Pump3/;

var PumpStation{TIME,PUMP} Binary;

The objective function is minimized power usage.

The constraints I am working on is once the pump is on, it has to run for at least 2 hours.

The valve is the following :

var Valve{TIME} Binary;

var ValveFlow{TIME} integer;

con Flow_pb: ValveFlow[t] >= 200*Valve[t];

con Flow_lb: ValveFlow[t] <= 1000*Valve[t];

The new constraints adding in the valve is once the valve is open, the flow needs to be same for at least 4 hours.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I recommend declaring your time periods as follows, with the interpretation that 0 corresponds to 8am:

```
set TIME = 0..23;
```

Then declare the following additional binary variable and linear constraints:

```
var StartPumpStation{TIME,PUMP} binary;
/* if PumpStation[t,p] = 1 and PumpStation[t-1,p] = 0 then StartPumpStation[t,p] = 1 */
con StartPumpStationCon1 {t in TIME, p in PUMP: t-1 in TIME}:
PumpStation[t,p] - PumpStation[t-1,p] <= StartPumpStation[t,p];
/* if StartPumpStation[t,p] = 1 then PumpStation[t-1,p] = 0 */
con StartPumpStationCon2 {t in TIME, p in PUMP: t-1 in TIME}:
StartPumpStation[t,p] <= 1 - PumpStation[t-1,p];
/* if StartPumpStation[t,p] = 1 then PumpStation[t,p] = PumpStation[t+1,p] = 1 */
con StartPumpStationCon3 {t in TIME, p in PUMP, t2 in t..t+1: t+1 in TIME}:
StartPumpStation[t,p] <= PumpStation[t2,p];
```

For the valve flows, define lower and upper bounds in the declaration:

```
var ValveFlow{TIME} integer >= 0 <= 1000;
```

Then declare another binary variable and linear constraints:

```
var StartValve {TIME} binary;
/* if Valve[t] = 1 and Valve[t-1] = 0 then StartValve[t] = 1 */
con StartValveCon1 {t in TIME: t-1 in TIME}:
Valve[t] - Valve[t-1] <= StartValve[t];
/* if StartValve[t] = 1 then Valve[t-1] = 0 */
con StartValveCon2 {t in TIME: t-1 in TIME}:
StartValve[t] <= 1 - Valve[t-1];
/* if StartValve[t] = 1 then Valve[t] = 1 */
con StartValveCon3 {t in TIME}:
StartValve[t] <= Valve[t];
/* if StartValve[t] = 1 then ValveFlow[t] = ValveFlow[t+1] = ValveFlow[t+2] = ValveFlow[t+3] */
con StartValveCon4 {t in TIME, t2 in t..t+2: t+3 in TIME}:
ValveFlow[t2] - ValveFlow[t2+1] <= (ValveFlow[t2].ub - ValveFlow[t2+1].lb) * (1 - StartValve[t]);
con StartValveCon5 {t in TIME, t2 in t..t+2: t+3 in TIME}:
ValveFlow[t2+1] - ValveFlow[t2] <= (ValveFlow[t2+1].ub - ValveFlow[t2].lb) * (1 - StartValve[t]);
```

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi there,

I only need it for one day. So starting at 8 am and ending at 7 am the next day. doesn't need to wrap it up. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I recommend declaring your time periods as follows, with the interpretation that 0 corresponds to 8am:

```
set TIME = 0..23;
```

Then declare the following additional binary variable and linear constraints:

```
var StartPumpStation{TIME,PUMP} binary;
/* if PumpStation[t,p] = 1 and PumpStation[t-1,p] = 0 then StartPumpStation[t,p] = 1 */
con StartPumpStationCon1 {t in TIME, p in PUMP: t-1 in TIME}:
PumpStation[t,p] - PumpStation[t-1,p] <= StartPumpStation[t,p];
/* if StartPumpStation[t,p] = 1 then PumpStation[t-1,p] = 0 */
con StartPumpStationCon2 {t in TIME, p in PUMP: t-1 in TIME}:
StartPumpStation[t,p] <= 1 - PumpStation[t-1,p];
/* if StartPumpStation[t,p] = 1 then PumpStation[t,p] = PumpStation[t+1,p] = 1 */
con StartPumpStationCon3 {t in TIME, p in PUMP, t2 in t..t+1: t+1 in TIME}:
StartPumpStation[t,p] <= PumpStation[t2,p];
```

For the valve flows, define lower and upper bounds in the declaration:

```
var ValveFlow{TIME} integer >= 0 <= 1000;
```

Then declare another binary variable and linear constraints:

```
var StartValve {TIME} binary;
/* if Valve[t] = 1 and Valve[t-1] = 0 then StartValve[t] = 1 */
con StartValveCon1 {t in TIME: t-1 in TIME}:
Valve[t] - Valve[t-1] <= StartValve[t];
/* if StartValve[t] = 1 then Valve[t-1] = 0 */
con StartValveCon2 {t in TIME: t-1 in TIME}:
StartValve[t] <= 1 - Valve[t-1];
/* if StartValve[t] = 1 then Valve[t] = 1 */
con StartValveCon3 {t in TIME}:
StartValve[t] <= Valve[t];
/* if StartValve[t] = 1 then ValveFlow[t] = ValveFlow[t+1] = ValveFlow[t+2] = ValveFlow[t+3] */
con StartValveCon4 {t in TIME, t2 in t..t+2: t+3 in TIME}:
ValveFlow[t2] - ValveFlow[t2+1] <= (ValveFlow[t2].ub - ValveFlow[t2+1].lb) * (1 - StartValve[t]);
con StartValveCon5 {t in TIME, t2 in t..t+2: t+3 in TIME}:
ValveFlow[t2+1] - ValveFlow[t2] <= (ValveFlow[t2+1].ub - ValveFlow[t2].lb) * (1 - StartValve[t]);
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you very much Rob

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.