OK, in this example, we are going to solve a very fun and optimization problem.
Suppose you are going to play the game called Clash of Clans.
So in this game, you have to train your troops to fight against other clans, OK?
And each of your, let's say soldiers have different characteristics.
They have maximum different maximum heat pumps and heat points or.
This example is referring to the clash of clans game, and we are going to unmowed as a linear kind
of programming, um, if you are familiar with this game and you do have different groups and each of
them has different characteristics, the amount of heat points you can tolerate, amount of damage it
can cause, and the training time is different for every, um, single troop.
And sometimes you want to attack your enemies and you want to have maximum hit points, you or you might
want to maximize the attacking capabilities and you want to do it at the minimum training time.
OK, so, uh.
Depending on how much you want and to tolerate damage or how much damage you can cause or how long does
it take to train your troop, or how much cost does it create to train your troop?
And your strategy for training the troops is different.
So, as I said, depending on your troop and they have different requirements and different costs,
so some of them take more time to train and they use more.
And Axia, OK.
And, um, so in order to find out the best strategy to train your troops, uh, you can create an optimization
problem and solve it for yourself.
So, as I said, there are multiple number of troops that you can train and, uh, each of them has
its own characteristics.
So, uh, in order to do that, um, the attack capabilities of each troop is stored in a parameter
called the tank or heat or time of training.
And EXI is telling Gown's how many of each troop you are going to choose.
So obviously you have to choose and the integer kind of variables to model that properly.
And also the housing of the camps are limited.
So multiply by housing summation is should be less than the camp capacity and also, uh, based on the
availability of Lexia and your training costs should be limited.
OK, so, um, for solving this model, you do need to have the, um, different characteristics associated
with, um.
Each troop, for example, in this, that's fine, um, you can see that different troops here, you
can see them here have different characteristics housing, space and damage they can create.
Training cast in using Red Lexia or dark lexia is different.
The amount of heat point they can tolerate is different training.
Time is different for all of them.
And the capacity of your camp should be specified here.
And the availability of your red or dark elixir is also specified in this python code.
OK, so let's have a look at the Python code itself.
So first of all, as usual, we have to import all the required packages and then we have to declare
the parameters that we are going to use.
For example, um, set I is representing every troop you have and also these parameters like housing,
space, damage, training costs, red training, cornstalk hit point training time, camp capacity and
also read lexia availability and um, availability should be a specified and also how many of each.
Um.
True, you have to train and should be defined by a variable called X and that X, for example, since
your camp has at two hundred eighty, I think, capacity, so the number of troops cannot be more than
that.
Um, and also they are coming from non-negative integers, so positive integers and initialize them
with zero and also total attack, uh, capability, total heat point and also the time required for
training those troops is also specified.
So there are some rules or some constraints that are defined here.
And I will explain some of them for you.
For example, the amount of damage total attack is exceptional to buy by damage.
I summation overall I in the model and also the total, um, housing is space should be less than your
account capacity of your camp.
And also the required red Alexia's should be less than your available rather lexia.
The same for dark lexia.
And also um the total heat point is defined over and heat multiplied by Exide summation over I.
And also finally the training time is defined as follows.
So we do have three objective, uh, functions.
This is the tricky point.
OK, so, um, in plomo, uh, you can't have more than one objective function.
OK, so that's fine.
If you define three objectives and it doesn't depend what name you choose here.
This is the key word which is important here.
Um, but you can define them, but you can't have them all active in your model, so you specify your
solver.
I use GLP K because it's a linear integer programming and you have to deactivate two of them and just
keep one of them.
So I deactivate objective two and three.
I have activated objective one.
It's not really necessary for the first time because it's already activated and then create instance
using the data I already showed you and of the results, uh, it gives you the final solutions so it
can tell you that if you want to maximize the damage, you have to.
Put all your efforts in training wizards, OK, and one goblin, um, or for example, if you want to,
uh, make the objective number to activate it, let's have a look.
What was the objective to object to is total heat point.
OK, so if you want to maximize your heat point, you have to train giants.
OK, and that's it.
So you can change your objective functions.
You can change your availability of the red lexia or a dark Alexiou and see what will happen to your,
um, capability of the troops.
Thank you very much.