The Objective Function: What Is Actually Being Maximised
An objective function attaches one number to every allowed plan, and any two of them can then be put in order. No rule can do that job: a rule sorts plans into allowed and not allowed and then falls silent. The Amaltas workshop’s objective is Rs 300/- a plain crate plus Rs 450/- a lined crate, and it ranks all eighty four allowed plans.
Two pieces of ground sit under all of this. One is the Amaltas workshop, invented for teaching, a place that turns out a plain crate and a lined crate and nothing besides, already described elsewhere together with the rupees each crate leaves behind. The other is the settled point that a rule sorts every plan into allowed and not allowed and then has nothing further to say. Getting past that silence takes a second kind of statement altogether, and an objective function is that statement.
What is an objective function, in plain words?
An objective function is a recipe. The recipe takes a plan and returns one number, and that number is the whole of what the recipe has to say. Nothing else comes out of it. The recipe does not say whether the plan is sensible, whether the workshop can afford it, or whether anybody would want the crates. The number exists for exactly one purpose: two plans can be compared by comparing two figures instead of by arguing.
Think about a household choosing between two rented flats. One is nearer the station, one has an extra room, and one is Rs 3,000/- a month cheaper. While those three things stay separate, two people can look at the same pair of flats and reach opposite answers, and neither of them is wrong. There is nothing yet for either of them to be wrong about. The moment somebody says out loud that ten minutes off the walk to the station is worth Rs 2,000/- a month and the extra room is worth Rs 4,000/-, the argument is finished. Not because anybody was persuaded, but because a single figure now exists for each flat, and single figures can be put in order.
Putting a single figure on each option is the entire requirement, and it has two halves that people drop. An objective must return a number for every allowed plan, not merely for the ones somebody finds interesting. And it must return one number rather than a list of three things that matter. If two things genuinely matter, how much of one is worth how much of the other has to be settled before the ranking can start. A ranking cannot begin until that trade has been decided. Refusing to decide it does not keep the options open. The decision only gets made later and quietly, by whoever writes the arithmetic down.
What must an objective function return, and for which plans?
What is the Amaltas workshop’s objective, written out?
Here it is in one line. Take the number of plain crates and multiply by Rs 300/-. Take the number of lined crates and multiply by Rs 450/-. Add the two together. The whole recipe is those three steps, and whatever the day’s plan turns out to be, the recipe turns that plan into one figure. The Rs 300/- and the Rs 450/- are each crate’s contributionThe rupees a crate leaves behind after the materials that went into that single crate are settled. Profit it is not, because the bills that arrive whatever gets made are still to come off., and both figures were invented for the workshop and have been held fixed ever since.
| The day’s plan | The arithmetic | What the recipe returns |
|---|---|---|
| 8 plain crates, 6 lined crates | 2,400 plus 2,700 | Rs 5,100/- |
| 6 plain crates, 7 lined crates | 1,800 plus 3,150 | Rs 4,950/- |
| 4 plain crates, 8 lined crates | 1,200 plus 3,600 | Rs 4,800/- |
| 11 plain crates, no lined crates | 3,300 plus 0 | Rs 3,300/- |
| No crates made at all | 0 plus 0 | Rs 0/- |
Look at what the recipe did with the last row. Making no crates at all is a perfectly ordinary day at the workshop, a bad one, and the recipe did not refuse it, did not complain, and did not point out that the workshop could obviously do better. The recipe returned Rs 0/-, the correct answer to the question it was asked. An objective function never says a plan is not allowed. Saying so is not its job, and it has no machinery for doing it. Hand this same recipe thirty plain crates and it will return Rs 9,000/- without hesitating. Thirty plain crates would want sixty bench hoursA single hour at a single workbench with a person working at it. There are three benches, each open eight hours, and two of the hours that come out of that go every day to setting up. against the twenty two that exist, so the workshop could not reach that figure on its best day.
Now run it over everything. Eighty four plans made of whole cratesNobody buys two thirds of a crate, so each count moves in ones. Whole counts are what let the allowed plans be written out as a finite list instead of a smear. are allowed by the workshop’s three daily limits. Feed all eighty four through the recipe and eighty four figures come back, and those figures lay out in a single line from Rs 0/- at one end to Rs 5,100/- at the other. The line of eighty four figures is what the objective bought, and no rule anywhere in the problem could have produced it.
The eighty four figures come out at 34 distinct values, so a handful of plans share a place in the line. Two different plans both come out at Rs 4,800/- a day. An objective is allowed to tie two plans, and a tie is information rather than a nuisance. A tie is the objective saying plainly that it cannot tell those two apart. Whether that is fine or whether it is a hole in the recipe is a question the last section below returns to.
Constraint vs Objective Function: which one is doing which job?
Most of the trouble in this subject comes from meeting a constraint and an objective already mixed together. Take the two apart before putting them next to each other.
A constraint is a sentence about what is allowed. Hand it a plan and it answers yes or no. The Amaltas workshop’s board rule charges a single board against every plain crate and a pair against every lined one, and says the total must come to at most twenty. Hand it six plain and seven lined, it does the addition, gets twenty, and says yes. A rule’s entire output is that one word. Yes.
An objective function is a recipe for a number. Hand it a plan and it answers with a figure. Hand the same six plain and seven lined to Rs 300/- a plain crate plus Rs 450/- a lined crate and it says Rs 4,950/-. An objective’s entire output is that one number. A figure.
Now set the two beside each other. The difference between them is not a shade of emphasis. A constraint says what is allowed. An objective says what is better. A rule and an objective answer different kinds of question, and neither can be bent into doing the other’s work.
Ask the board rule which of two allowed plans is the better one and it has nothing whatsoever to say. The rule is not being difficult. A rule genuinely does not contain the information. Both plans got a yes, the two yeses are identical, and there is no third thing inside the rule to break the tie with. Ask the objective whether a plan is allowed and it is equally helpless in the opposite direction, as the thirty crate answer above already showed. The objective did not lie. Worth is the only question an objective can answer, and worth is the question it answered.
The two even look different once they are written down. A constraint has an at most or an at least in it, and a number sitting on the other side of that phrase. An objective has the words as large as possible, or as small as possible, and no number on the other side at all. The entire point is that the number is not yet known. If a line in somebody’s problem carries a limit, it is sorting. If it carries a direction and no limit, it is ranking. Reading every line of a problem for that one feature clears away a good deal of the confusion here before any arithmetic is done.
When the two do get confused, the failure has a shape that is worth learning to recognise. A solverA piece of software handed the rules and the thing to make large, which hands back the plan it believes is best. How it can be confidently wrong is covered separately. handed a rule where an objective belonged returns something legal and useless: a plan that passes every check, that nobody can fault, and that is quietly worse than another plan sitting a crate or two away from it. The next two sections show that happening twice, once in each direction, with the money counted both times.
In one line each, what does a constraint do and what does an objective do?
What happens when a target is used as the objective?
Here is the first swap, and it is much the more common of the two. Somebody at the Amaltas workshop decides that the aim for the day is to use every board. Use every board sounds like an aim. The aim has the right shape, it is easy to check by looking at the rack at closing time, and nothing gets wasted. Twenty boards arrive on the standing orderA delivery of a fixed size that turns up whether or not the day needs all of it, so its cost stays the same when the plan changes.; use twenty boards.
Work out which plans actually hit it. A plain crate eats a single board and a lined crate eats a pair, so the plans that use exactly twenty are the ones whose two counts add up that way to twenty. Solve that against the workshop’s other two limits and exactly three whole crate plans survive.
| The plan | Boards used | Score on the aim | Worth in a day |
|---|---|---|---|
| 8 plain crates, 6 lined crates | 8 plus 12, so 20 | 20 of 20 | Rs 5,100/- |
| 6 plain crates, 7 lined crates | 6 plus 14, so 20 | 20 of 20 | Rs 4,950/- |
| 4 plain crates, 8 lined crates | 4 plus 16, so 20 | 20 of 20 | Rs 4,800/- |
| Between the best and the worst of them | no difference | no difference | Rs 300/- a day |
All three score full marks against the stated aim, and Rs 300/- a day separates the best of them from the worst. One thing to clear out of the way before it confuses anybody: that spread happens to come out at the same figure as what a single plain crate adds to a day, and there is no link of any kind between them. Two unrelated sums sometimes come out equal, and reading a connection into that coincidence would be reading a connection into nothing.
So which of the three does the aim choose? The aim does not choose. It cannot. Full marks against full marks is not a comparison, it is a tie, and the aim has no second ingredient inside it to break the tie with. A solver pointed at use every board will hand back one of the three, will print the word optimal beside it, and which of the three comes back depends on things that have nothing to do with the workshop at all: the order the solver happened to walk the cornersThe points where two of the limit lines cross and the shape of allowed plans turns a sharp angle. Why a best answer so often lands on one of them is covered separately. in, or the way a tie is broken inside somebody else’s code. The aim did not decide. Something else did, and nobody wrote that something down.
Three plans all use every board. Which of them does the aim use every board choose?
What happens when the objective is turned into a rule?
Now the swap in the other direction, which is rarer, quieter, and does its damage just as thoroughly. Say the workshop keeps contribution but changes what it does with it. Instead of ranking plans by contribution, it writes a rule: the day must bring in at least Rs 4,800/- of contribution. Then it hands over the three daily limits, this new rule, and nothing at all to make large.
Four of the eighty four allowed plans clear the bar.
| The plan | Worth in a day | Against the bar | What the problem now says about it |
|---|---|---|---|
| 8 plain crates, 6 lined crates | Rs 5,100/- | clears it | Acceptable |
| 6 plain crates, 7 lined crates | Rs 4,950/- | clears it | Acceptable |
| 7 plain crates, 6 lined crates | Rs 4,800/- | exactly meets it | Acceptable |
| 4 plain crates, 8 lined crates | Rs 4,800/- | exactly meets it | Acceptable |
| The other 80 allowed plans | under Rs 4,800/- | fail it | Not acceptable |
A rule sorts and a rule does not rank. All four are now equally acceptable, and nothing left in the problem distinguishes them. The workshop has taken the one thing in the problem capable of putting plans in order and demoted it to a box that gets ticked. Rs 5,100/- is not better than Rs 4,800/- any more. Both of them pass, and passing is all there is.
The bar could of course be raised further. Set at Rs 4,950/- it lets two plans through. Set just above Rs 5,100/- none clear it; set just under, one survives, and that one is the right plan. So has the rule found the answer? Consider what had to be known in order to set the bar there. The best plan had to be known already in order to place the bar just underneath it. The answer was fed into the rule rather than got out of it. A rule that is tuned by somebody who already has the ranking is not doing the ranking. The rule is repeating a ranking somebody else already did.
And that trick is not always even available. The panel below tightens a different rule, the one about how many boards a plan must use, and no setting of it ever leaves a single plan standing. Tightening a rule shortens a list. Whether the shortened list happens to have one item in it is luck, and an unordered list of one is still an unordered list.
The workshop makes contribution a rule at Rs 4,800/- a day instead of an objective. What has it lost?
Before the control below is touched: the rule about boards used is about to be tightened from none to all twenty. Does tightening it eventually leave one plan?
However hard the rule is tightened, it still will not choose.
Below is a rule the Amaltas workshop might add on top of its three daily limits: the day’s plan must use at least so many of the twenty boards. Slide it from none to all twenty. The dots that satisfy the rule stay lit, the rest dim, and the line underneath shows what the survivors are worth. Watch the count fall and watch what never happens to the order.
Educational illustration. Both crate values and all three of the daily limits stay exactly where they are while the board rule alone moves, and nothing but whole crate plans is counted.
What makes an objective function a good one?
Four tests, and all four can be run on the back of an envelope before anybody writes any code.
| Test | What it asks | How it fails | The Amaltas workshop’s objective against it |
|---|---|---|---|
| One | Does it return a number for every allowed plan? | Loudly. The objective crashes on the plan it cannot score | Passes. All eighty four get a figure |
| Two | Is it one number rather than a wish list? | Loudly. Nothing can be ranked and somebody notices | Passes. Rupees a day, one column |
| Three | Does it move with the outcome that actually matters? | In silence. The objective computes cleanly and answers the wrong question | Passes here, and only because the Rs 4,300/- is the same on every plan |
| Four | Is it measurable from what already gets recorded? | Loudly. Nothing anywhere records the figure it needs | Passes. Crate counts are written down every evening |
The third test is the one that fails quietly, and that is what makes it dangerous. The other three fail loudly. An objective that cannot score some plan crashes on that plan. An objective made of three things refuses to produce a ranking and somebody notices within the hour. An objective built on a figure nobody records cannot be computed at all. In every one of those cases the failure shows up fast. Test three fails in complete silence. The objective computes cleanly, ranks everything it is given, and hands back a confident answer to a question nobody asked.
The everyday version is easy to feel. A household decides that its one number is the money going out each month, and that smaller is better. Nothing is wrong with the arithmetic. Stop paying the insurance premium and the number goes down, so the month scores better. The objective did exactly what it was told. Test three is what broke. Keeping the outgo small was standing in for something bigger, and the stand in got promoted to the real thing while nobody was watching.
An objective passes three of the four tests but is a convenient stand in for what the workshop actually wants. Which test failed?
Why does an almost right objective give a different plan?
Bench hours cost the workshop money whether they are used or not, so somebody proposes maximising the bench hours used. Maximising bench hours used is close to right, and that is exactly what makes it worth working through. Bench hours really are among the scarcest things in the workshop. The best plan really does use all twenty two of them. So the objective is pointed at something real rather than at nonsense.
Work out which plans use all twenty two. A plain crate eats two hours at the bench and a lined crate eats one, so the plans that use exactly twenty two are the ones whose two counts add up that way to twenty two. Put that against the other two limits and four whole crate plans survive.
| The plan | Bench hours used | Score on the aim | Worth in a day |
|---|---|---|---|
| 11 plain crates, no lined crates | 22 plus 0, so 22 | 22 of 22 | Rs 3,300/- |
| 10 plain crates, 2 lined crates | 20 plus 2, so 22 | 22 of 22 | Rs 3,900/- |
| 9 plain crates, 4 lined crates | 18 plus 4, so 22 | 22 of 22 | Rs 4,500/- |
| 8 plain crates, 6 lined crates | 16 plus 6, so 22 | 22 of 22 | Rs 5,100/- |
| Between the best and the worst of them | no difference | no difference | Rs 1,800/- a day |
Every one of those four scores a perfect twenty two out of twenty two on the stated objective, and Rs 1,800/- a day separates the best of them from the worst. Rs 1,800/- is more than a third of the best day the workshop can have, sitting hidden inside a perfect score. And notice the specific plan that gets away with it. Eleven plain crates and no lined ones, worth Rs 3,300/- a day, is a plan a bench hours objective is perfectly happy with. The plan uses every hour. The plan also leaves nine of the twenty boards untouched and every roll of cloth on the shelf. Nobody put boards or cloth into the objective, so the objective has no opinion at all about either.
An objective that is nearly the right one is not nearly as good. A near miss is a different objective, and different objectives have different answers. The distance between its best answer and its worst answer, here Rs 1,800/- a day, is a fair measure of how much has been handed over to chance. The bench hours proposal is not a silly one. Somebody proposing it could give sound reasons. Sound reasons and the right objective are two different things.
Four plans all use every bench hour and are worth between Rs 3,300/- and Rs 5,100/- a day. What does that say about maximising hours used?
What do the four orderings of the same plans look like side by side?
Everything above comes off one set of plans. The eighty four the Amaltas workshop is allowed. Here are four ways of putting that one set in order, on one table.
| Put the eighty four in order by | What comes first | How many tie at the top | Spread among the tied |
|---|---|---|---|
| Contribution, the objective itself | 8 plain and 6 lined, Rs 5,100/- a day | 1 | none |
| Boards used | Three plans, all on 20 boards | 3 | Rs 300/- a day |
| Bench hours used | Four plans, all on 22 hours | 4 | Rs 1,800/- a day |
| Contribution turned into a rule at Rs 4,800/- | Nothing comes first. Four plans qualify | 4 | Rs 300/- a day |
One set of plans, four orderings, and only one of the four answers the question the workshop actually meant to ask. Read down the last column. Every row except the first has a spread hiding inside it, and a spread inside a tie is money that nothing in the problem is choosing about.
There is a fifth ordering worth naming and then setting firmly aside. Ranking the plans by how many crates get made in a day makes the winner eight plain and six lined, fourteen crates, and fourteen crates is the right plan. The crate count agrees. The agreement is still not a check on anything, and it must never be used as one. Agreeing by accident and being right are two different states, and no ordering can tell the two apart from the outside. An objective that happens to give the right answer on one problem will give a different one on the next, and there is no warning when it does.
The aim on the wall, met perfectly, every single day
The Amaltas workshop paints use every board on the wall of the shop floor and reports against it. Every evening somebody writes down how many of the twenty boards were used, and every evening the answer is twenty. The aim is being met, and it goes on being met, and nobody has any reason to look at it again.
The plan the workshop settles into is four plain crates and eight lined crates. Nothing pushed it there on purpose. The lined crate is the one that brings in more per crate, the aim on the wall says nothing whatsoever about that, and given a free choice among the three plans that use every board, a workshop that likes lined crates drifts to the one with the most of them.
Every board is used. The aim is met. The day is worth Rs 4,800/-, and the same twenty boards, put to eight plain crates and six lined, would have been worth Rs 5,100/-. The shortfall is Rs 300/- a day, every working day, and it appears nowhere in any report. The report measures the aim, and the aim is being hit exactly.
The fix is one sentence long: a target is something to check, and an objective is something to rank by. The ranking gets written down. Then the target, if it is wanted at all, sorts plans in or out before the ranking starts. Nothing stops the workshop from wanting to use every board. The mistake is asking that want to do a job it has no machinery for.
The workshop hits its stated aim every day and is Rs 300/- a day short. How would anybody notice?
What should be asked of an objective somebody hands over?
Reading somebody else’s objective is the commonest version of this problem, and it survives when the workshop is forgotten. An analyst reading somebody else’s model, a lender being shown how a borrower decides what to build, or anybody handed a spreadsheet whose bottom row is labelled best plan, is in the same position: a number is being maximised, and the interesting question is whether it is the right one. Five questions do most of the work, and they take about two minutes.
What one number is it? Rupees of contribution in a day. Not crates, not hours, not rupees of revenue, and the units matter as much as the name does.
Does every allowed plan get one? Yes, all eighty four, including the day where nothing gets made.
Is it the thing actually wanted, or a convenient stand in? A stand in, and an honest one. Contribution is not profit. Once the costs that do not moveRent, wages and the standing board order. The three of them come to Rs 4,300/- a day here and stay exactly the same whichever plan the workshop runs. are paid, the best day is worth Rs 800/-. The Rs 4,300/- is the same on every plan, so ranking by contribution still picks the same plan. The stand in is safe here for that reason alone, and it would not be safe if the Rs 4,300/- moved.
What does it treat as free? Everything inside the Rs 4,300/-. Also the two rolls of cloth left idle at the best plan. Cloth is not in the objective, so the objective never mentions cloth.
Which plans does it think are tied? Two of the eighty four, both landing on Rs 4,800/- a day.
The last question is the sharpest of the five. An objective that ties two plans that can be told apart is missing something already known. At a tie, if a preference between the two plans does exist, then that preference was information the objective never had. The honest move at that point is to put it into the objective, not to break the tie by hand every morning and call it judgement. A tie is where an objective has run out of opinion, and it says so plainly.
Why is which plans does it think are tied the sharpest question to put to an objective?
Covered elsewhere. How a rule gets written down and read is covered separately, and so is what an extra board or an extra hour of bench time fetches in rupees, and so is the case of a plan that breaks a rule outright instead of merely ranking badly. A curved objective, whose winning plan lies partway along an edge rather than at one of the sharp angles, is likewise dealt with elsewhere. Deciding what share of a set of holdings each one should take, with risk weighed against return along the way, sits inside investment management and is dealt with there.
Who stands behind the figures printed above?
Nobody, and that is the accurate answer rather than a gap. The table below names each figure, the listing that produced it, and the one thing somebody redoing it by hand is most likely to get wrong. Arithmetic on an invented workshop can only be checked by redoing it, and the last column names the slip most likely to spoil the redoing.
| The figure | The listing that produced it | The slip to watch for when the work is redone |
|---|---|---|
| Eighty four allowed plans | Every pair of crate counts walked in turn and each pair put through all three daily limits | Forgetting that a lined crate takes two boards, and so shortening the count |
| Rs 5,100/- at eight plain and six lined | All eighty four scored and compared, not just the corners | Comparing corners only, which assumes the answer sits at one |
| The three plans on twenty boards | The board line solved, then each solution tested against hours and cloth | Keeping seven plain and eight lined, which needs twenty three boards |
| The four plans on twenty two bench hours | The bench hours line solved the same way and tested the same way | Keeping twelve plain, which the twenty two hours will not stretch to |
| Rs 300/- and Rs 1,800/- of spread | One subtraction each, taken between two exact rupee figures | Subtracting figures that were rounded first, which moves the answer |
| What the words constraint and objective function mean | Ordinary mathematical usage, put into plain words here | Nothing to redo. Crediting a single text without opening it would be worse than crediting none |
The Amaltas workshop, its plain crate and its lined crate are invented.
Educational material. Not advice on any investment, tax, budget or market position.
