1. A method in an electronic device, the method comprising: determining an algorithm based on at least one of information about environments and information about a useful amount of resources; determining a variable of the determined algorithm based on the at least one of information about the environments and information about the useful amount of resources; and executing the determined algorithm based on the determined variable of the algorithm.