Labor Optimizer in a nutshell
Total Jobs = Jobs Per Dwarf * # of Dwarf's
(ex: 10 * 100 = 1000)
% Jobs to assign = Total Jobs * % desiring to assign.
(ex: 80% of 1000 jobs, will only assign 800 jobs, some dwarf's will have filled up their Jobs Per Dwarf, i.e. 10, where-as 200 jobs will not be assigned, so some dwarf's will have less than 10 jobs per). This is useful when you have dwarf's that are good at a lot of jobs, where-as some dwarf's just suck and are good at a few, and you want to use these few that don't have their max "Jobs Per Dwarf" reached for other things, such as a default hauling custom profession.
The ratio works like this
ratio for that job / (sum of ratio's) = % of the % Jobs to assign.
Ex.
Mining 3 ratio = 8.3% of jobs = 66 Dwarf's assigned to that labor
Woodcutting 1 ratio = 2.7% of jobs = 22 Dwarf's...
Masonry 2 ratio = 5.5% of jobs * 800 Jobs = 44 Dwarf's...
Rest of Jobs... total ratio = 30
Total Ratio: 36
There is a miner/woodcutter/ambusher check coded here
http://www.bay12forums.com/smf/index.php?topic=66525.msg3822047#msg3822047It checks to make sure the # of (miners + woodcutters + ambusher; due to the equipping bug) < Population, else it reduces the ratio's of these labors to ensure they add up to population, and then adds to the total ratio for the rest of the jobs
Here is code on how a list of jobs is created based on a dwarf's role, and the priority of the job
http://www.bay12forums.com/smf/index.php?topic=66525.msg3796316#msg3796316hopefully the notes (i.e. //comments) help explain how it's loaded