Skip to content

Commit

Permalink
Updated recommend_website
Browse files Browse the repository at this point in the history
- moved condition
- modified if to else

Co-authored-by: Jonas Geertsen Lund <[email protected]>
  • Loading branch information
thor1878 and JonasGLund99 committed Dec 20, 2021
1 parent 0ba35ff commit 9514d79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion input/simulation_input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ NUM_WEBSITES 50
NUM_CATEGORIES 16
AVG_USER_TIME 11520
SIM_DURATION_DAYS 7
NUM_SIMULATIONS 100
NUM_SIMULATIONS 10
SUSTAINABLE_CHOICE_INCREMENT 0.05
17 changes: 10 additions & 7 deletions src/lib/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,25 @@ Website *recommend_website(WebsiteNode **linked_websites, Website *current_websi
num_common_interactions = 0;
num_total_interactions = 0;

/* Make sure that the user itself is skipped */
if (similar_user_index == user_index) {
continue;
}

/* Loop through all websites and compare the inputted user (user_id) and the 'y'th user */
for (int x = 0; x < num_alternatives_in_category; x++) {
/* Make sure that the user itself is skipped */
if (similar_user_index == user_index) {
continue;
}

/* If both values are NULL, skip to the next iteration in the for loop */
else if (matrix[similar_user_index + x] == NULL && matrix[user_index + x] == NULL) {
if (matrix[similar_user_index + x] == NULL && matrix[user_index + x] == NULL) {
continue;
}
/* Else if both values are the same, increment num_common_interactions */
else if (matrix[similar_user_index + x] == matrix[user_index + x]) {
num_common_interactions++;
num_total_interactions++;
}
/* If one of the values are not -1, increment num_total_interactions */
if (matrix[similar_user_index + x] != NULL || matrix[user_index + x] != NULL) {
/* If one of the values are not NULL, increment num_total_interactions */
else {
num_total_interactions++;
}
}
Expand Down

0 comments on commit 9514d79

Please sign in to comment.