/** * Identifies inactive constraints. * * @param tree branch and bound tree * @param list indices of inactive constraints * @return number of inactive constraints */ private int inactive(glp_tree tree, SWIGTYPE_p_int list) { glp_attr attr = new glp_attr(); int p = GLPK.glp_ios_curr_node(tree); int lev = GLPK.glp_ios_node_level(tree, p); int i, cnt = 0; for (i = GLPK.glp_get_num_rows(prob); i >= 1; i--) { GLPK.glp_ios_row_attr(tree, i, attr); if (attr.level < lev) { break; } if (attr.origin != GLPK.GLP_RF_REG) { if (GLPK.glp_get_row_stat(prob, i) == GLPK.GLP_BS) { cnt++; if (list != null) { GLPK.intArray_setitem(list, cnt, i); } } } } Console.WriteLine(cnt + " inactive constraints removed"); return(cnt); }
/// <summary> /// Détecte les contraintes inactives /// </summary> /// <param name="tree">Arbre de recherche</param> /// <param name="list">Liste de retour</param> /// <returns>Nombre de contraintes à éliminer</returns> private int inactive(glp_tree tree, SWIGTYPE_p_int list) { glp_attr attr = new glp_attr(); int p = GLPK.glp_ios_curr_node(tree); //Indice du noeud courant int lev = GLPK.glp_ios_node_level(tree, p); //Niveau dans l'arbre int i, cnt = 0; //On parcours les lignes et on les ajoutes à la liste si elles sont inactives for (i = GLPK.glp_get_num_rows(problem); i >= 1; i--) { GLPK.glp_ios_row_attr(tree, i, attr); if (attr.level < lev) { break; } if (attr.origin != GLPK.GLP_RF_REG) { if (GLPK.glp_get_row_stat(problem, i) == GLPK.GLP_BS) { cnt++; if (list != null) { GLPK.intArray_setitem(list, cnt, i); } } } } logger.log(cnt + " inactive constraints removed", Message.Level.Normal); return(cnt); }
public void callback(glp_tree tree) { if (GLPK.glp_ios_reason(tree) == GLPK.GLP_IROWGEN) { string prt = ""; for (int i = 0; i < data.nodeList.Count; i++) { for (int j = 0; j < data.nodeList.Count - 1; j++) { int j2 = j; if (j >= i) { j2++; } prt += i + "->" + j2 + " : " + GLPK.glp_get_col_prim(problem, arc[i, j2]) + " ;"; } } Console.WriteLine(prt); remove_inactive(tree); generate_rows(); } }
public void callback(glp_tree tree) { int reason = GLPK.glp_ios_reason (tree); if (reason == GLPK.GLP_IBINGO) { Console.WriteLine ("Better solution found"); } }
/// <summary> /// Détecte les contraintes inactives /// </summary> /// <param name="tree">Arbre de recherche</param> /// <param name="list">Liste de retour</param> /// <returns>Nombre de contraintes à éliminer</returns> private int inactive(glp_tree tree, SWIGTYPE_p_int list) { glp_attr attr = new glp_attr(); int p = GLPK.glp_ios_curr_node(tree); int lev = GLPK.glp_ios_node_level(tree, p); int i, cnt = 0; //On parcours les lignes et on les ajoutes à la liste si elles sont inactives for (i = GLPK.glp_get_num_rows(problem); i >= 1; i--) { GLPK.glp_ios_row_attr(tree, i, attr); if (attr.level < lev) { break; } if (attr.origin != GLPK.GLP_RF_REG) { if (GLPK.glp_get_row_stat(problem, i) == GLPK.GLP_BS) { cnt++; if (list != null) { GLPK.intArray_setitem(list, cnt, i); } } } } return(cnt); }
/** * Method call by the GLPK MIP solver in the branch-and-cut algorithm. * * @param tree search tree */ public void callback(glp_tree tree) { if (GLPK.glp_ios_reason(tree) == GLPK.GLP_IROWGEN) { remove_inactive(tree); generate_rows(); } }
/** * Callback method called by native library. * @param cPtr pointer to search tree */ public static void callback(IntPtr cPtr) { glp_tree tree; tree = new glp_tree(cPtr, false); foreach (IGlpkCallbackListener listener in listeners) { listener.callback(tree); } }
public void callback(glp_tree tree) { int reason = GLPK.glp_ios_reason(tree); if (reason == GLPK.GLP_IBINGO) { Console.WriteLine("Better solution found"); } }
/** * Callback method called by native library. * @param cPtr pointer to search tree */ public static void callback(IntPtr cPtr) { glp_tree tree; tree = new glp_tree(cPtr, false); foreach (IGlpkCallbackListener listener in listeners.Value) { listener.callback(tree); } }
/// <summary> /// Supprime les contraintes inactives /// </summary> /// <param name="tree">Arbre de recherche</param> private void remove_inactive(glp_tree tree) { int cnt; SWIGTYPE_p_int clist; cnt = inactive(tree, null); //Récupère les contraintes inactives if (cnt > 0) { clist = GLPK.new_intArray(cnt + 1); inactive(tree, clist); GLPK.glp_del_rows(problem, cnt, clist); //On supprime les contraintes inactives } }
private void remove_inactive(glp_tree tree) { /* remove inactive transitivity constraints */ int cnt; SWIGTYPE_p_int clist; cnt = inactive(tree, null); if (cnt > 0) { clist = GLPK.new_intArray(cnt + 1); inactive(tree, clist); GLPK.glp_del_rows(prob, cnt, clist); } }
public void callback(glp_tree tree) { glp_prob prob; if (GLPK.glp_ios_reason (tree) == GLPK.GLP_IROWGEN) { prob = GLPK.glp_ios_get_prob (tree); if (forceError) { GLPK.glp_cli_set_msg_lvl (GLPK.GLP_CLI_MSG_LVL_ALL); try { GLPK.glp_add_rows (prob, -1); } catch (GlpkException ex) { Console.WriteLine ("Error in callback: " + ex.Message); } GLPK.glp_cli_set_msg_lvl (GLPK.GLP_CLI_MSG_LVL_OFF); } } }
public void callback(glp_tree tree) { glp_prob prob; if (GLPK.glp_ios_reason(tree) == GLPK.GLP_IROWGEN) { prob = GLPK.glp_ios_get_prob(tree); if (forceError) { GLPK.glp_cli_set_msg_lvl(GLPK.GLP_CLI_MSG_LVL_ALL); try { GLPK.glp_add_rows(prob, -1); } catch (GlpkException ex) { Console.WriteLine("Error in callback: " + ex.Message); } GLPK.glp_cli_set_msg_lvl(GLPK.GLP_CLI_MSG_LVL_OFF); } } }