aboutsummaryrefslogtreecommitdiff
path: root/src/ats/libgnunet_plugin_ats_mlp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/libgnunet_plugin_ats_mlp.c')
-rw-r--r--src/ats/libgnunet_plugin_ats_mlp.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/ats/libgnunet_plugin_ats_mlp.c b/src/ats/libgnunet_plugin_ats_mlp.c
index f45c5fe0b..1d921776d 100644
--- a/src/ats/libgnunet_plugin_ats_mlp.c
+++ b/src/ats/libgnunet_plugin_ats_mlp.c
@@ -1078,10 +1078,12 @@ mlp_propagate_results (void *cls,
1078} 1078}
1079 1079
1080static void notify (struct GAS_MLP_Handle *mlp, 1080static void notify (struct GAS_MLP_Handle *mlp,
1081 enum GAS_Solver_Operation op, enum GAS_Solver_Status stat) 1081 enum GAS_Solver_Operation op,
1082 enum GAS_Solver_Status stat,
1083 enum GAS_Solver_Additional_Information add)
1082{ 1084{
1083 if (NULL != mlp->env->info_cb) 1085 if (NULL != mlp->env->info_cb)
1084 mlp->env->info_cb (mlp->env->info_cb_cls, op, stat); 1086 mlp->env->info_cb (mlp->env->info_cb_cls, op, stat, add);
1085} 1087}
1086/** 1088/**
1087 * Solves the MLP problem 1089 * Solves the MLP problem
@@ -1103,36 +1105,36 @@ GAS_mlp_solve_problem (void *solver)
1103 mlp->bulk_request ++; 1105 mlp->bulk_request ++;
1104 return GNUNET_NO; 1106 return GNUNET_NO;
1105 } 1107 }
1106 notify (mlp, GAS_OP_SOLVE_START, GAS_STAT_SUCCESS); 1108 notify (mlp, GAS_OP_SOLVE_START, GAS_STAT_SUCCESS, GAS_INFO_NONE);
1107 1109
1108 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers)) 1110 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers))
1109 { 1111 {
1110 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS); 1112 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE);
1111 return GNUNET_OK; /* No pending requests */ 1113 return GNUNET_OK; /* No pending requests */
1112 } 1114 }
1113 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->addresses)) 1115 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->addresses))
1114 { 1116 {
1115 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS); 1117 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE);
1116 return GNUNET_OK; /* No addresses available */ 1118 return GNUNET_OK; /* No addresses available */
1117 } 1119 }
1118 1120
1119 if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated)) 1121 if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated))
1120 { 1122 {
1121 LOG (GNUNET_ERROR_TYPE_DEBUG, "No changes to problem\n"); 1123 LOG (GNUNET_ERROR_TYPE_DEBUG, "No changes to problem\n");
1122 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS); 1124 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE);
1123 return GNUNET_OK; 1125 return GNUNET_OK;
1124 } 1126 }
1125 if (GNUNET_YES == mlp->mlp_prob_changed) 1127 if (GNUNET_YES == mlp->mlp_prob_changed)
1126 { 1128 {
1127 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n"); 1129 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n");
1128 notify (mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS); 1130 notify (mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS, GAS_INFO_MLP_FULL);
1129 mlp_delete_problem (mlp); 1131 mlp_delete_problem (mlp);
1130 if (GNUNET_SYSERR == mlp_create_problem (mlp)) 1132 if (GNUNET_SYSERR == mlp_create_problem (mlp))
1131 { 1133 {
1132 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_FAIL); 1134 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_FAIL, GAS_INFO_MLP_FULL);
1133 return GNUNET_SYSERR; 1135 return GNUNET_SYSERR;
1134 } 1136 }
1135 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS); 1137 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_MLP_FULL);
1136 mlp->control_param_lp.presolve = GLP_YES; 1138 mlp->control_param_lp.presolve = GLP_YES;
1137 mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ 1139 mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */
1138 } 1140 }
@@ -1142,20 +1144,28 @@ GAS_mlp_solve_problem (void *solver)
1142 } 1144 }
1143 1145
1144 /* Run LP solver */ 1146 /* Run LP solver */
1147
1148 notify (mlp, GAS_OP_SOLVE_LP_START, GAS_STAT_SUCCESS,
1149 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED);
1145 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running LP solver %s\n", 1150 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running LP solver %s\n",
1146 (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver"); 1151 (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver");
1147 notify (mlp, GAS_OP_SOLVE_LP_START, GAS_STAT_SUCCESS);
1148 res_lp = mlp_solve_lp_problem (mlp); 1152 res_lp = mlp_solve_lp_problem (mlp);
1149 notify (mlp, GAS_OP_SOLVE_LP_STOP, (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL); 1153 notify (mlp, GAS_OP_SOLVE_LP_STOP,
1154 (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
1155 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED);
1150 1156
1151 1157
1152 /* Run MLP solver */ 1158 /* Run MLP solver */
1153 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n"); 1159 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n");
1154 notify (mlp, GAS_OP_SOLVE_MLP_START, GAS_STAT_SUCCESS); 1160 notify (mlp, GAS_OP_SOLVE_MLP_START, GAS_STAT_SUCCESS,
1161 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED);
1155 res_mip = mlp_solve_mlp_problem (mlp); 1162 res_mip = mlp_solve_mlp_problem (mlp);
1156 notify (mlp, GAS_OP_SOLVE_MLP_STOP, (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL); 1163 notify (mlp, GAS_OP_SOLVE_MLP_STOP,
1157 1164 (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
1158 notify (mlp, GAS_OP_SOLVE_STOP, (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL); 1165 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED);
1166 notify (mlp, GAS_OP_SOLVE_STOP,
1167 (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
1168 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED);
1159 1169
1160 /* Save stats */ 1170 /* Save stats */
1161 mlp->ps.lp_res = res_lp; 1171 mlp->ps.lp_res = res_lp;