Modelling simulation and analysis of genetic algorithm for function optimization and stock portfolio selection