From e889bcb650e7460978bfe2a75c53da47fc44ce3e Mon Sep 17 00:00:00 2001
From: Antonio Andriella <aandriella@iri.upc.edu>
Date: Sun, 29 Nov 2020 23:33:07 +0100
Subject: [PATCH] add close file to fix bug

---
 .../1000/True/1/bn_variables.csv               | 10 ++++++++++
 .../1000/True/1/log_gen.csv                    |  1 +
 .../1000/True/1/log_params.csv                 |  2 ++
 .../1000/True/1/log_spec.csv                   |  2 ++
 .../1000/True/1/log_summary.csv                |  1 +
 .../1000/True/2/bn_variables.csv               | 12 ++++++++++++
 .../1000/True/2/log_gen.csv                    |  6 ++++++
 .../1000/True/2/log_params.csv                 |  2 ++
 .../1000/True/2/log_spec.csv                   | 12 ++++++++++++
 .../1000/True/2/log_summary.csv                |  2 ++
 .../1000/True/3/bn_variables.csv               |  9 +++++++++
 .../1000/True/3/log_gen.csv                    |  6 ++++++
 .../1000/True/3/log_params.csv                 |  2 ++
 .../1000/True/3/log_spec.csv                   |  9 +++++++++
 .../1000/True/3/log_summary.csv                |  2 ++
 therapistBNInit.py                             | 18 +++++++++---------
 16 files changed, 87 insertions(+), 9 deletions(-)
 create mode 100644 therapist-patient-interaction/1000/True/1/bn_variables.csv
 create mode 100644 therapist-patient-interaction/1000/True/1/log_gen.csv
 create mode 100644 therapist-patient-interaction/1000/True/1/log_params.csv
 create mode 100644 therapist-patient-interaction/1000/True/1/log_spec.csv
 create mode 100644 therapist-patient-interaction/1000/True/1/log_summary.csv
 create mode 100644 therapist-patient-interaction/1000/True/2/bn_variables.csv
 create mode 100644 therapist-patient-interaction/1000/True/2/log_gen.csv
 create mode 100644 therapist-patient-interaction/1000/True/2/log_params.csv
 create mode 100644 therapist-patient-interaction/1000/True/2/log_spec.csv
 create mode 100644 therapist-patient-interaction/1000/True/2/log_summary.csv
 create mode 100644 therapist-patient-interaction/1000/True/3/bn_variables.csv
 create mode 100644 therapist-patient-interaction/1000/True/3/log_gen.csv
 create mode 100644 therapist-patient-interaction/1000/True/3/log_params.csv
 create mode 100644 therapist-patient-interaction/1000/True/3/log_spec.csv
 create mode 100644 therapist-patient-interaction/1000/True/3/log_summary.csv

diff --git a/therapist-patient-interaction/1000/True/1/bn_variables.csv b/therapist-patient-interaction/1000/True/1/bn_variables.csv
new file mode 100644
index 0000000..123cd42
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/1/bn_variables.csv
@@ -0,0 +1,10 @@
+user_action,game_state,attempt,agent_assistance
+2,0,0,0
+0,0,1,1
+2,0,0,2
+0,0,1,1
+2,1,0,0
+0,1,1,3
+2,1,0,1
+0,1,1,2
+0,2,0,2
diff --git a/therapist-patient-interaction/1000/True/1/log_gen.csv b/therapist-patient-interaction/1000/True/1/log_gen.csv
new file mode 100644
index 0000000..95898a2
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/1/log_gen.csv
@@ -0,0 +1 @@
+cum_elapsed_time,to,cum_react_time,from,timeout,user_action,token_id,caregiver_feedback,avg_caregiver_assistance_per_move,attempt
diff --git a/therapist-patient-interaction/1000/True/1/log_params.csv b/therapist-patient-interaction/1000/True/1/log_params.csv
new file mode 100644
index 0000000..acad1a9
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/1/log_params.csv
@@ -0,0 +1,2 @@
+with_feedback,objective,session,user_id,timeout
+True,descending_odd,1,1,15
diff --git a/therapist-patient-interaction/1000/True/1/log_spec.csv b/therapist-patient-interaction/1000/True/1/log_spec.csv
new file mode 100644
index 0000000..8e5a12d
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/1/log_spec.csv
@@ -0,0 +1,2 @@
+game_state,user_action,attempt,caregiver_feedback,react_time,caregiver_assistance,user_react_time,from,elapsed_time,to,timeout,token_id
+0,2,0,0,15,0,0,,0,,0,
diff --git a/therapist-patient-interaction/1000/True/1/log_summary.csv b/therapist-patient-interaction/1000/True/1/log_summary.csv
new file mode 100644
index 0000000..72d795f
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/1/log_summary.csv
@@ -0,0 +1 @@
+tot_elapsed_time,avg_lev_assistance,tot_react_time,n_timeout,n_attempt,n_sociable
diff --git a/therapist-patient-interaction/1000/True/2/bn_variables.csv b/therapist-patient-interaction/1000/True/2/bn_variables.csv
new file mode 100644
index 0000000..e0288b5
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/2/bn_variables.csv
@@ -0,0 +1,12 @@
+user_action,game_state,attempt,agent_assistance
+1,0,0,0
+2,0,1,1
+0,0,2,2
+2,0,0,1
+0,0,1,2
+2,1,0,1
+0,1,1,2
+2,1,0,1
+1,1,1,2
+0,1,2,3
+0,2,0,1
diff --git a/therapist-patient-interaction/1000/True/2/log_gen.csv b/therapist-patient-interaction/1000/True/2/log_gen.csv
new file mode 100644
index 0000000..6982083
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/2/log_gen.csv
@@ -0,0 +1,6 @@
+cum_elapsed_time,to,cum_react_time,from,timeout,user_action,token_id,caregiver_feedback,avg_caregiver_assistance_per_move,attempt
+0.916,1,6.416,8,1,,565,0,0.0,3
+0.772,2,0.785,6,2,,499,0,0.0,2
+0.475,3,7.12,9,3,,321,0,0.0,2
+0.99,4,2.044,18,4,,311,0,0.0,3
+0.0,5,0.0,15,4,,177,0,0.0,1
diff --git a/therapist-patient-interaction/1000/True/2/log_params.csv b/therapist-patient-interaction/1000/True/2/log_params.csv
new file mode 100644
index 0000000..0b6a7cf
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/2/log_params.csv
@@ -0,0 +1,2 @@
+with_feedback,objective,session,user_id,timeout
+True,descending_odd,2,1,15
diff --git a/therapist-patient-interaction/1000/True/2/log_spec.csv b/therapist-patient-interaction/1000/True/2/log_spec.csv
new file mode 100644
index 0000000..58a6873
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/2/log_spec.csv
@@ -0,0 +1,12 @@
+game_state,user_action,attempt,caregiver_feedback,react_time,caregiver_assistance,user_react_time,from,elapsed_time,to,timeout,token_id
+0,1,0,0,0.0,0,2,19,0.0,19,0,135
+0,2,1,0,15,0,0,,0,,0,
+0,0,2,0,6.416,0,1,8,0.916,1,1,565
+0,2,0,0,15,0,0,,0,,1,
+0,0,1,0,0.785,0,2,6,0.772,2,2,499
+1,2,0,0,15,0,0,,0,,2,
+1,0,1,0,7.12,0,1,9,0.475,3,3,321
+1,2,0,0,15,0,0,,0,,3,
+1,1,1,0,2.044,0,2,15,0.99,0,4,177
+1,0,2,0,0.0,0,2,18,0.0,4,4,311
+2,0,0,0,0.0,0,2,15,0.0,5,4,177
diff --git a/therapist-patient-interaction/1000/True/2/log_summary.csv b/therapist-patient-interaction/1000/True/2/log_summary.csv
new file mode 100644
index 0000000..bd39f73
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/2/log_summary.csv
@@ -0,0 +1,2 @@
+tot_elapsed_time,avg_lev_assistance,tot_react_time,n_timeout,n_attempt,n_sociable
+3.1530000000000005,0.0,16.365000000000002,14,11,0
diff --git a/therapist-patient-interaction/1000/True/3/bn_variables.csv b/therapist-patient-interaction/1000/True/3/bn_variables.csv
new file mode 100644
index 0000000..71a3758
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/3/bn_variables.csv
@@ -0,0 +1,9 @@
+user_action,game_state,attempt,agent_assistance
+0,0,0,0
+0,0,0,1
+2,1,0,0
+0,1,1,2
+1,1,0,1
+0,1,1,3
+1,2,0,1
+0,2,1,2
diff --git a/therapist-patient-interaction/1000/True/3/log_gen.csv b/therapist-patient-interaction/1000/True/3/log_gen.csv
new file mode 100644
index 0000000..dfcc82d
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/3/log_gen.csv
@@ -0,0 +1,6 @@
+cum_elapsed_time,to,cum_react_time,from,timeout,user_action,token_id,caregiver_feedback,avg_caregiver_assistance_per_move,attempt
+0.0,1,0.0,1,0,,715,0,0.0,1
+0.0,2,0.0,7,0,,671,0,0.0,1
+0.0,3,0.0,16,1,,667,0,0.0,2
+0.0,4,0.0,12,1,,661,0,0.0,2
+0.0,5,0.0,14,1,,619,0,0.0,2
diff --git a/therapist-patient-interaction/1000/True/3/log_params.csv b/therapist-patient-interaction/1000/True/3/log_params.csv
new file mode 100644
index 0000000..a33c192
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/3/log_params.csv
@@ -0,0 +1,2 @@
+with_feedback,objective,session,user_id,timeout
+True,descending_odd,3,1,15
diff --git a/therapist-patient-interaction/1000/True/3/log_spec.csv b/therapist-patient-interaction/1000/True/3/log_spec.csv
new file mode 100644
index 0000000..8e4f736
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/3/log_spec.csv
@@ -0,0 +1,9 @@
+game_state,user_action,attempt,caregiver_feedback,react_time,caregiver_assistance,user_react_time,from,elapsed_time,to,timeout,token_id
+0,0,0,0,0.0,0,2,1,0.0,1,0,715
+0,0,0,0,0.0,0,2,7,0.0,2,0,671
+1,2,0,0,15,0,0,,0,,0,
+1,0,1,0,0.0,0,2,16,0.0,3,1,667
+1,1,0,0,0.0,0,2,12,0.0,0,1,661
+1,0,1,0,0.0,0,2,12,0.0,4,1,661
+2,1,0,0,0.0,0,2,14,0.0,0,1,619
+2,0,1,0,0.0,0,2,14,0.0,5,1,619
diff --git a/therapist-patient-interaction/1000/True/3/log_summary.csv b/therapist-patient-interaction/1000/True/3/log_summary.csv
new file mode 100644
index 0000000..734ee4b
--- /dev/null
+++ b/therapist-patient-interaction/1000/True/3/log_summary.csv
@@ -0,0 +1,2 @@
+tot_elapsed_time,avg_lev_assistance,tot_react_time,n_timeout,n_attempt,n_sociable
+0.0,0.0,0.0,3,8,0
diff --git a/therapistBNInit.py b/therapistBNInit.py
index 64cc37e..0678f13 100644
--- a/therapistBNInit.py
+++ b/therapistBNInit.py
@@ -165,8 +165,8 @@ parser.add_argument('--with_feedback', '--f', type=eval, choices=[True, False],
 args = parser.parse_args()
 
 run_batch = True
-from_id = 1
-to_id = 10
+from_id = 11
+to_id = 18
 
 if run_batch == False:
     user_id = args.user_id
@@ -302,13 +302,10 @@ else:
             max_value_for_user = 15
             max_value_for_assistance = 30
 
-            attempt_preferences_for_correct_move = attempt_given_user#[2, 3, 4, 4]
-            assistance_preferences_for_correct_move = user_given_assistance#[2, 3, 3, 4, 5, 5]
-            game_preferences_for_correct_move = game_given_user#[2, 3, 4]
-            assistance_preferences_for_correct_move_game_attempt = assistance_given_attempt_game#[[4, 5, 2, 1, 1, 1],
-                                      # [1, 3, 5, 3, 1, 1],
-                                      # [1, 2, 2, 5, 4, 1],
-                                      # [1, 1, 2, 5, 4, 4]]
+            attempt_preferences_for_correct_move = attempt_given_user
+            assistance_preferences_for_correct_move = user_given_assistance
+            game_preferences_for_correct_move = game_given_user
+            assistance_preferences_for_correct_move_game_attempt = assistance_given_attempt_game
 
             user_action_vars = ["(correct)", "(wrong)", "(timeout)"]
             agent_assistance_vars = ["(lev_0)", "(lev_1)", "(lev_2)", "(lev_3)", "(lev_4)", "(lev_5)"]
@@ -358,6 +355,7 @@ else:
                                  str(bn_models.assistance_preferences[elem][1])+","+
                                  str(bn_models.assistance_preferences[elem][2])+"; \n")
             user_model.write("}")
+            user_model.close()
 
             agent_model.write("probability (agent_assistance | game_state, attempt) { \n")
             bn_models.agent_assistance_preferences_on_attempt_game = bn_models.get_agent_assistance_given_attempt_and_game_state(assistance_preferences_for_correct_move_game_attempt)
@@ -377,6 +375,8 @@ else:
                                       )
                     it += 1
             agent_model.write("}")
+            agent_model.close()
+
 
 
             print(bn_models.attempt_preferences)
-- 
GitLab