How to write code for Assignment problem using GA matlab tool.
Show older comments
How to write code for Assignment problem using GA matlab tool.I'm not sure how to write code for xij=0 or 1.
Please clarify my doubt. Thanks in advance.
Answers (1)
John D'Errico
on 19 Jun 2022
0 votes
Does GA allow you to specify that some variables are integer? (Yes.)
Does GA allow you to specify lower and upper bound limits on the variables? (Yes.)
Which integers lie in the closed interval [0,1]? (I'll let you answer that.)
11 Comments
buvaneshwari tk
on 19 Jun 2022
buvaneshwari tk
on 19 Jun 2022
buvaneshwari tk
on 19 Jun 2022
Sam Chak
on 19 Jun 2022
Not an expert in operations research, but I do hope the Example and MATLAB code in the following link help:
John D'Errico
on 19 Jun 2022
Edited: John D'Errico
on 19 Jun 2022
First, you cannot simultaneously maximize AND minimize two different objectives, using an optimization tool.
You cannot simultaneuously optimize two separate things at once. Except that you can, but you need to use ideas from the field of multi-criteria optimization. In MATLAB, there is the tool fgoalattain, except that it cannot handle integer constraints.
Next, as pointed out by @Sam Chak, this is a linear problem, except that you cannot use a tool like intlinprog to solve that problem. (You would want intlinprog, because of the integer constraints. linprog has no ability to solve integer problems.)
Finally, since you have only 16 total variables, each of which can take on only two values, the simplest solution is to just evaluate the objectives for all possible sets of the parameters. That would look as if you have 65536=2^16 possible combinations. But as importantly, the constraints make it obvious that in fact, you don't have that many ways to do this. In fact, your constraints force this to be a problem where all of the matrices must be permutation matrices. There are only 24 possible 4x4 permutation matrices. We can find all 24 of them as permutations of the 4x4 identity matrix. So start with the 4x4 identity.
X = eye(4);
PermsList = perms(1:4)
As I said, 24 of them. We can find all admissable permutations as:
X = permute(reshape(X(PermsList,:),[24 4 4]),[2 3 1]);
For example, one such admissable permutation is:
X(:,:,5)
As you can see, each of them satisfy all of your constraints.
X
Now you could merely loop through every possible plane of that array. Test them all, taking the one that makes you happy.
Regardless, you will still need to decide how to simultaneously choose between two disparate objectives, because the set that optimizes one will not be the set that optimizes the other. You will need to decide how to combine the two objectives into one.
Would you want to use GA to do this? Why in the name of god and little green apples would you do that, or even use intlinprog, when there are only 24 such possible matrices to consider?
buvaneshwari tk
on 19 Jun 2022
buvaneshwari tk
on 19 Jun 2022
Torsten
on 19 Jun 2022
For this code i get the values of varibles in between 0 and 1.
i want the value of variable in 0 or 1.
To achieve this, set
intcons = 1:16
And better use intlinprog instead of ga - it will be way faster.
buvaneshwari tk
on 23 Jun 2022
buvaneshwari tk
on 23 Jun 2022
Categories
Find more on Multiobjective Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!