For the drawbacks such as low optimization precision and sticking to local optimum with the classic bacteria foraging optimization (BFO), a variable probability and hybrid BFO (VHBFO) algorithm is presented. Emerged from the information sharing mechanism of particle swarm optimization (PSO), the chemotaxis direction strategy reflecting the bacteria individual cognitive and group cooperation is proposed, so as to improve the precision and searching efficiency of the algorithm. The variable probability of migration operations based on the group fitness variance theory is introduced to avoid the premature convergence and help bacteria quickly jump out of local extremum and avoid elite bacteria escape. The improved good point set population is used to construct the initial population and new individuals after migration, which provides a more uniform and diversified solution space. Experiment results indicate that the algorithm outperforms the classic algorithm both in terms of the solution accuracy and the convergence speed.