In ubiquitous computing, shared environments adjust themselves so that all users in the environments are satisfied as possible. Inevitably, some of users sacrifice their satisfactions while the shared environments maximize the sum of all users’ satisfactions. In our previous work, we have proposed social welfare functions to avoid a situation which some users in the system face the worst setting of environments. In this work, we consider a more direct approach which is a preference based clustering to handle this issue. In this approach, first, we categorize all users into several subgroups in which users have similar tastes to environmental parameters based on their preference information. Second, we assign the subgroups into different time or space of the shared environments. Finally, each shared environments can be adjusted to maximize satisfactions of each subgroup and consequently the optimal of overall system can be achieved. We demonstrate the effectiveness of our approach with a numerical analysis.