Optimized scheduling to demand based on constraints

sdoppke

Well-known Member
Joined
Jun 10, 2010
Messages
647
The title kind of states my goal. I am looking for some help to get started to solve the problem of scheduling a group of people based on demand and their individual constraints, using solver and VBA (or maybe a combo of the two?)

Here is a picture to describe what I am looking for help to create via solver/vba:

unavailable
FTEmp. 1
After 7PMFTEmp. 2MinMax
FTEmp. 3
FTEmp. 4
FTEmp. 5MinMax
FTEmp. 6
FTEmp. 7
FTEmp. 8
FTEmp. 9
FTEmp. 10
After 2PM
After 3PMPTEmp. 12
PTEmp. 13
PTEmp. 14
PTEmp. 15
PTEmp. 16
PTEmp. 17
PTEmp. 18
FTEmp. 19
PTEmp. 20
FTEmp. 21
PTEmp. 22
FTEmp. 23

<colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:2676;width:58pt" width="77"> <col style="mso-width-source:userset;mso-width-alt:791;width:17pt" width="23"> <col style="width:48pt" width="64" span="2"> <col style="mso-width-source:userset;mso-width-alt:2443;width:53pt" width="70"> <col style="mso-width-source:userset;mso-width-alt:3072;width:66pt" width="88"> <col style="width:48pt" width="64" span="15"> </colgroup><tbody>
[TD="width: 64"][/TD]
[TD="width: 77"]A[/TD]
[TD="width: 23"]B[/TD]
[TD="width: 64"]C[/TD]
[TD="width: 64"]D[/TD]
[TD="width: 70"]E[/TD]
[TD="width: 88"]F[/TD]
[TD="width: 64"]G[/TD]
[TD="width: 64"]H[/TD]
[TD="width: 64"]I[/TD]
[TD="width: 64"]J[/TD]
[TD="width: 64"]K[/TD]
[TD="width: 64"]L[/TD]
[TD="width: 64"]M[/TD]
[TD="width: 64"]N[/TD]
[TD="width: 64"]O[/TD]
[TD="width: 64"]P[/TD]
[TD="width: 64"]Q[/TD]
[TD="width: 64"]R[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]

[TD="align: right"]1[/TD]

[TD="class: xl66"]Time of Day[/TD]
[TD="class: xl66"]9:00 AM[/TD]
[TD="class: xl66"]10:00 AM[/TD]
[TD="class: xl66"]11:00 AM[/TD]
[TD="class: xl66"]12:00 PM[/TD]
[TD="class: xl66"]1:00 PM[/TD]
[TD="class: xl66"]2:00 PM[/TD]
[TD="class: xl66"]3:00 PM[/TD]
[TD="class: xl66"]4:00 PM[/TD]
[TD="class: xl66"]5:00 PM[/TD]
[TD="class: xl66"]6:00 PM[/TD]
[TD="class: xl66"]7:00 PM[/TD]
[TD="class: xl66"]8:00 PM[/TD]
[TD="class: xl66"]9:00 PM[/TD]
[TD="class: xl66"]10:00 PM[/TD]

[TD="align: right"]2[/TD]

[TD="class: xl70"] [/TD]
[TD="class: xl71"]Total Zone Demand/Hr[/TD]
[TD="class: xl71"]5[/TD]
[TD="class: xl71"]6[/TD]
[TD="class: xl71"]5[/TD]
[TD="class: xl71"]6[/TD]
[TD="class: xl71"]9[/TD]
[TD="class: xl71"]11[/TD]
[TD="class: xl71"]10[/TD]
[TD="class: xl71"]13[/TD]
[TD="class: xl71"]15[/TD]
[TD="class: xl71"]18[/TD]
[TD="class: xl71"]13[/TD]
[TD="class: xl71"]9[/TD]
[TD="class: xl71"]5[/TD]
[TD="class: xl71"]1[/TD]
[TD="class: xl71"]126[/TD]

[TD="align: right"]3[/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]8[/TD]

[TD="colspan: 2"]FT Hr. Contraints[/TD]

[TD="align: right"]4[/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]9[/TD]

[TD="align: right"]5[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="align: right"]8[/TD]

[TD="class: xl67"]6[/TD]
[TD="class: xl67"]9[/TD]

[TD="align: right"]6[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]7[/TD]

[TD="colspan: 2"]PT Hr. Constraints[/TD]

[TD="align: right"]7[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]7[/TD]

[TD="align: right"]8[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]8[/TD]

[TD="align: right"]4[/TD]
[TD="align: right"]6[/TD]

[TD="align: right"]9[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]8[/TD]

[TD="align: right"]10[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]8[/TD]

[TD="align: right"]11[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]6[/TD]

[TD="align: right"]12[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]0[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]8[/TD]

[TD="align: right"]13[/TD]

[TD="class: xl68"]PT[/TD]
[TD="class: xl68"]Emp. 11[/TD]
[TD="class: xl69"]1[/TD]
[TD="class: xl69"]1[/TD]
[TD="class: xl69"]1[/TD]
[TD="class: xl69"]1[/TD]
[TD="class: xl69"]1[/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl68"] [/TD]
[TD="class: xl68"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl68, align: right"]5[/TD]

[TD="align: right"]14[/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]

[TD="class: xl67"][/TD]
[TD="align: right"]4[/TD]

[TD="align: right"]15[/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]

[TD="class: xl67"][/TD]
[TD="align: right"]4[/TD]

[TD="align: right"]16[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]5[/TD]

[TD="align: right"]17[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]4[/TD]

[TD="align: right"]18[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]4[/TD]

[TD="align: right"]19[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]6[/TD]

[TD="align: right"]20[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]5[/TD]

[TD="align: right"]21[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]4[/TD]

[TD="align: right"]22[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]4[/TD]

[TD="align: right"]23[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]

[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"]1[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]4[/TD]

[TD="align: right"]24[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]0[/TD]

[TD="align: right"]25[/TD]

[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[TD="align: right"]0[/TD]

[TD="align: right"]26[/TD]

[TD="class: xl65"]Scheduled[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]126[/TD]

[TD="align: right"]27[/TD]

[TD="class: xl65"]Variance[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]

</tbody>

Row 2 has the demand needed per hour (totals 126 hours for the day).
For each employee throughout the day, I use a 1 or 0 to represent the shift work time and lunch (1 is an hour worked and 0 is lunch).
Row 26 is the total of the 1's (hours worked).
Rows 27 is the variance row 2 and row 26.
Column A states when a person is unavailable.
Off to the right side you will see full time employees (FT) need to work between 6 and 9 hours a shift with either a 30 minute or 1 hours lunch, and PT employees need to work between 4 and 6 hours per shift (no lunch).

The part I am looking for help on is to use solver/vba to fill in cells D3:Q25 by using all the hours available (in this case 126 hours), with the least absolute variance total in row 27. My example shows 0 variance but many times there is a small absolute variance.

Thanks in advance for any help or direction.

SD
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hello everyone. Bumping this back up. I know it's complex. Does anyone have ideas? Happy to explain further if needed.

THanks!
SD
 
Upvote 0
Hello everyone. Bumping this back up. I know it's complex. Does anyone have ideas? Happy to explain further if needed.

THanks!
SD



These get buried quickly. Bumping again to find some Excel MVPs that might be able to help.

SD
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top