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

Showing results for

- 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**.
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 11-09-2021 02:49 PM
(306 views)

I am using this example, and wondering what would have to change to use more than 1 truck to meet the demands of a node:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/casmopt/casmopt_decomp_examples12.htm

I adjusted the capacity down so that it would have to split between two trucks, but it becomes infeasible. I'm not totally sure which constraint is causing that to happen. I think it is the FlowBalance constraint, but not sure how it should adjust. Any help would be great.

Thanks,

Dan

1 ACCEPTED SOLUTION

Accepted Solutions

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

A heuristic idea is to keep the optimization model the same but modify the input data to split demands across multiple copies of the existing nodes. For example, the following DATA step splits nodes 8 and 17 in the input:

```
data vrpdata;
input node x y demand;
datalines;
1 145 215 0
2 151 264 1100
3 159 261 700
4 130 254 800
5 128 252 1400
6 163 247 2100
7 146 246 400
8.1 161 242 400
8.2 161 242 400
9 142 239 100
10 163 236 500
11 148 232 600
12 128 231 1200
13 156 217 1300
14 129 214 1300
15 146 208 300
16 164 208 900
17.1 141 206 500
17.2 141 206 500
17.3 141 206 500
17.4 141 206 500
17.5 141 206 100
18 147 193 1000
19 164 193 900
20 129 189 2500
21 155 185 1800
22 139 182 700
;
```

The resulting optimal solution has optimal objective value 585 instead of 603.

If you instead want the solver to determine the best way to split the demands, you can keep the original data and replace the FlowBalance constraints as follows:

```
* con FlowBalance {i in NODES diff {depot}, k in VEHICLES}:
sum {<j,(i)> in ARCS} Flow[j,i,k] - sum {<(i),j> in ARCS} Flow[i,j,k]
= demand[i] * UseNode[i,k];
var DemandSatisfied {NODES diff {depot}, VEHICLES} >= 0 <= capacity;
con FlowBalance {i in NODES diff {depot}, k in VEHICLES}:
sum {<j,(i)> in ARCS} Flow[j,i,k] - sum {<(i),j> in ARCS} Flow[i,j,k]
= DemandSatisfied[i,k];
con DemandSatisfaction {i in NODES diff {depot}}:
sum {k in VEHICLES} DemandSatisfied[i,k] = demand[i];
```

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

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

A heuristic idea is to keep the optimization model the same but modify the input data to split demands across multiple copies of the existing nodes. For example, the following DATA step splits nodes 8 and 17 in the input:

```
data vrpdata;
input node x y demand;
datalines;
1 145 215 0
2 151 264 1100
3 159 261 700
4 130 254 800
5 128 252 1400
6 163 247 2100
7 146 246 400
8.1 161 242 400
8.2 161 242 400
9 142 239 100
10 163 236 500
11 148 232 600
12 128 231 1200
13 156 217 1300
14 129 214 1300
15 146 208 300
16 164 208 900
17.1 141 206 500
17.2 141 206 500
17.3 141 206 500
17.4 141 206 500
17.5 141 206 100
18 147 193 1000
19 164 193 900
20 129 189 2500
21 155 185 1800
22 139 182 700
;
```

The resulting optimal solution has optimal objective value 585 instead of 603.

If you instead want the solver to determine the best way to split the demands, you can keep the original data and replace the FlowBalance constraints as follows:

```
* con FlowBalance {i in NODES diff {depot}, k in VEHICLES}:
sum {<j,(i)> in ARCS} Flow[j,i,k] - sum {<(i),j> in ARCS} Flow[i,j,k]
= demand[i] * UseNode[i,k];
var DemandSatisfied {NODES diff {depot}, VEHICLES} >= 0 <= capacity;
con FlowBalance {i in NODES diff {depot}, k in VEHICLES}:
sum {<j,(i)> in ARCS} Flow[j,i,k] - sum {<(i),j> in ARCS} Flow[i,j,k]
= DemandSatisfied[i,k];
con DemandSatisfaction {i in NODES diff {depot}}:
sum {k in VEHICLES} DemandSatisfied[i,k] = demand[i];
```

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

Thanks Rob!

We actually were doing a data solution and not even asking the solver to solve it, which was a little inefficient in cases where it could better make choices on how to fill trucks. As we add more and more to this problem I suspect we'll have to let the optimizer solve the best way to split trucks out.

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.