[gnumeric] nlsolve: minor improvements.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] nlsolve: minor improvements.
- Date: Sun, 23 May 2010 15:28:08 +0000 (UTC)
commit 19df5fcbc8672314cf1edeeeba2c5424e09975e9
Author: Morten Welinder <terra gnome org>
Date: Sun May 23 11:27:45 2010 -0400
nlsolve: minor improvements.
plugins/nlsolve/ChangeLog | 5 +++++
plugins/nlsolve/gnm-nlsolve.c | 24 ++++++++++--------------
src/dialogs/dialog-solver.c | 12 +++---------
3 files changed, 18 insertions(+), 23 deletions(-)
---
diff --git a/plugins/nlsolve/ChangeLog b/plugins/nlsolve/ChangeLog
index 45e20de..2b09e8f 100644
--- a/plugins/nlsolve/ChangeLog
+++ b/plugins/nlsolve/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-23 Morten Welinder <terra gnome org>
+
+ * gnm-nlsolve.c (gnm_nlsolve_idle): Use the axis-method even if
+ the Hessian is singular. Restore x0 if we fail to improve.
+
2010-05-21 Morten Welinder <terra gnome org>
* Initial Implementation
diff --git a/plugins/nlsolve/gnm-nlsolve.c b/plugins/nlsolve/gnm-nlsolve.c
index 8ef492a..1825b74 100644
--- a/plugins/nlsolve/gnm-nlsolve.c
+++ b/plugins/nlsolve/gnm-nlsolve.c
@@ -345,13 +345,11 @@ gnm_nlsolve_idle (gpointer data)
d = g_new (gnm_float, n);
ok = (gnm_linear_solve (H, g, n, d) == 0);
- if (!ok)
- goto stop;
-
- if (nl->debug)
- print_vector ("Delta", d, n);
-
- ok = try_direction (nl, x0, d);
+ if (ok) {
+ if (nl->debug)
+ print_vector ("Delta", d, n);
+ ok = try_direction (nl, x0, d);
+ }
if (!ok) {
int i, j;
@@ -380,6 +378,10 @@ gnm_nlsolve_idle (gpointer data)
}
if (!ok) {
+ int i;
+ for (i = 0; i < n; i++)
+ set_value (nl, i, x0[i]);
+
gnm_solver_set_status (sol, GNM_SOLVER_STATUS_DONE);
call_again = FALSE;
}
@@ -389,7 +391,6 @@ gnm_nlsolve_idle (gpointer data)
call_again = FALSE;
}
-out:
g_free (d);
g_free (x0);
g_free (g);
@@ -398,11 +399,6 @@ out:
g_free (H);
return call_again;
-
-stop:
- gnm_solver_stop (sol, NULL);
- call_again = FALSE;
- goto out;
}
static gboolean
@@ -460,7 +456,7 @@ nlsolve_solver_factory (GnmSolverFactory *factory, GnmSolverParameters *params)
nl->debug = gnm_solver_debug ();
nl->eps = gnm_pow2 (-25);
- nl->max_iter = 100;
+ nl->max_iter = 1000;
nl->min_factor = 1e-10;
nl->target = gnm_solver_param_get_target_cell (params);
diff --git a/src/dialogs/dialog-solver.c b/src/dialogs/dialog-solver.c
index bd6abd5..2bc7acb 100644
--- a/src/dialogs/dialog-solver.c
+++ b/src/dialogs/dialog-solver.c
@@ -974,6 +974,9 @@ dialog_init (SolverState *state)
for (i = 0; model_type_group[i]; i++) {
const char *bname = model_type_group[i];
GtkWidget *w = glade_xml_get_widget(state->gui, bname);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
+ param->options.model_type ==
+ (GnmSolverModelType)i);
g_signal_connect (G_OBJECT (w), "clicked",
G_CALLBACK (cb_dialog_model_type_clicked), state);
}
@@ -1116,15 +1119,6 @@ dialog_init (SolverState *state)
glade_xml_get_widget(state->gui, "min_button")),
param->problem_type == GNM_SOLVER_MINIMIZE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (
- glade_xml_get_widget(state->gui, "lp_model_button")),
- param->options.model_type == GNM_SOLVER_LP);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (
- glade_xml_get_widget(state->gui, "qp_model_button")),
- param->options.model_type == GNM_SOLVER_QP);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (
- glade_xml_get_widget(state->gui, "nlp_model_button")),
- param->options.model_type == GNM_SOLVER_NLP);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (
glade_xml_get_widget(state->gui, "no_scenario")),
! param->options.add_scenario);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]