So now, let's write down the constraints for this thing.

So first thing is you can't use the deal unless you buy enough arrows.

>> Right. >> Okay.

>> So it has to be more than and

what they specify in the voucher, right? >> Exactly.

If we basically look for

this merchant, do we use their deal?

Well, if we sum up the number of hours we bought at that merchant as part of

the buy with negative v.

Then that has to be greater than the number of acquired for

that merchant's deal.

Then we've used that merchant's deal, right, okay.

>> So we are using a C style kind of pseudo-boolean,

we are counting the number of trues, right?

>> Yeah, exactly.

>> Okay. >> We're counting the number of times that

this occurs.

>> Right, okay.

>> Okay, and then of course, if we don't use the deal, right?

>> Mm-hm. >> Then we have,

none of these negative v's should appear for that merchant v.

>> Mm-hm. >> because we're not using the deal.

>> Okay. >> So if we're not using the deal,

that should be zero.

If we use the deal of course the most we should have is actually the number we

need to buy.

There's no point buying 12 arrows to use daily, [INAUDIBLE] needs 10.

>> So this is actually tricky here.

I don't think it's specified in the specification but you know it's basically

saying that if we have to buy more arrows from that particular merchant.

But then the deal does not require us to buy that many arrows, then we might as

well just buy it using [INAUDIBLE] instead of buying it for the voucher, right?

>> Yeah, so the dominance rule says if I need to buy 10 arrows to use the deal,

there's no point in buying 12, because it's just more expensive.

>> Okay. >> Right, so

I'll always be better by just buying ten.

So it's a dormant rule if you want.

The next one is very similar in looking to the one above, which it says okay,

if you got the deal, so this deal is being used and

we can buy up to that many errors for free.

So if [INAUDIBLE], we are getting those errors for free from the merchant.

And of course, [INAUDIBLE] zero or false, then we can't get any for free.

So that constraint makes that happened.

>> Right. >> Okay, and then the last thing.

>> One more constraint.

>> It's the important one really which is whenever we

buy if whenever we get an error for free.

>> Yes. >> It can cost more

than any of the errors we bought.

>> For that particular deal.

>> For that particular deal.

>> Yeah. >> All right, so what are we doing?

We're looking through each pair of arrows.

>> Mm-hm.

>> Okay, so this how [INAUDIBLE] is less than how [INAUDIBLE].

So that means that we, so if you think about this way,

the only case we care about is we do this one [INAUDIBLE] of each other.

>> Right.

>> If the [INAUDIBLE] bought them from the same merchant.

One of them was bought and one of them was free.

>> Right. >> Okay, and

once we add, if we have that information,

and then we say that how[a1] is less than how[a2] it means that we pay for a1.

>> Mm-hm.

>> But we got a2 for free.

>> Because when we pay for a1, we have a- >> Right, you have negative v.

>> Negative v, you're right.

>> Yeah, okay.

>> Okay.

>> So if that's the case, if we pay for a1 and

we got a2 free, [INAUDIBLE] the price of a2 is less than or equal the price of a1.

>> That make sesne.

>> Okay, and

then of course the objective is just The total price that we pay, right?

Which is if I sum up for all the arrows, and if this how[a] is less or equal to 0,

than I pay for it, right, either as part of a deal or just order it normally.

And the other ones, I bet I get for free.

>> Right.

>> Okay, so there's our model there.

We can run it on some small data.

>> We should get something like that, right?

>> Okay. >> Okay,

so that was the test example that's in the handout.

>> All right. >> All right, but our role today is to

say, okay, how do we map this if we don't, so

we can run this actually using MIP solver.

So let's use the coin OR CBC solver, and that will run as well.

You can see it takes a little bit longer, 1 second versus 61 milliseconds.

>> Right.