A very simple question for GA
Show older comments
Dear all, I have a very simple question as follows, I just want to clarify if I am doing right or not:
I have a function named: function [wRemAlo] = Resource allocation (x)
x: have three possible values which I am entering in command line before running the function e.g. I put "x = [90,20,0,10]" and
After receiving the input values of x, my function allocate resources to 16 variables v (v(1) to v(16)) and return the single variable of "wRemAlo".
I want ga to minimise the output of the function: "wRemAlo"
My function is working correct and return the correct value for "wRemAlo" whenever I run it.
I put constraints as follows to put restrictions on ga decisions and pass the handle for the function to ga solver as follows:
ObjectiveFunction = @ResourceAllocation;
nvars = 16; A=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ; 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ; 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 ; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 ; 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ; 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 ; 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0 ; 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
b=[105;90;20;0;10;0;0;45;60]; LB = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
[v,fval] = ga(ObjectiveFunction,nvars,A,b,[],[],LB,[],[])
The fval value returns after running ga dose not make any sense! Should this value be as same as the value for the function output: "wRemAlo"
Please somebody tell me if I am doing correct or not??
regs, Melody
Accepted Answer
More Answers (1)
Nagh Meh
on 27 Jun 2012
Categories
Find more on Variables 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!