gnumeric r16310 - in branches/gnumeric-1-8: . src/tools/solver
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16310 - in branches/gnumeric-1-8: . src/tools/solver
- Date: Wed, 30 Jan 2008 02:33:13 +0000 (GMT)
Author: mortenw
Date: Wed Jan 30 02:33:12 2008
New Revision: 16310
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16310&view=rev
Log:
2008-01-29 Morten Welinder <terra gnome org>
* solver.c (lp_qp_solver_init): Take lhs' value for vars=0 into
account. In the typical case, that is vars itself, but in #512500
it is not.
(get_lp_coeff): Compute at x=1 first, then at x=0. Hence we leave
things at zero.
Modified:
branches/gnumeric-1-8/NEWS
branches/gnumeric-1-8/src/tools/solver/ChangeLog
branches/gnumeric-1-8/src/tools/solver/solver.c
Modified: branches/gnumeric-1-8/NEWS
==============================================================================
--- branches/gnumeric-1-8/NEWS (original)
+++ branches/gnumeric-1-8/NEWS Wed Jan 30 02:33:12 2008
@@ -2,6 +2,7 @@
Morten:
* Fix loading of solver constraints.
+ * Fix solver issue. [#512500]
--------------------------------------------------------------------------
Gnumeric 1.8.1
Modified: branches/gnumeric-1-8/src/tools/solver/solver.c
==============================================================================
--- branches/gnumeric-1-8/src/tools/solver/solver.c (original)
+++ branches/gnumeric-1-8/src/tools/solver/solver.c Wed Jan 30 02:33:12 2008
@@ -350,15 +350,15 @@
{
gnm_float x0, x1;
- gnm_cell_set_value (change, value_new_float (0.0));
+ gnm_cell_set_value (change, value_new_float (1));
cell_queue_recalc (change);
gnm_cell_eval (target);
- x0 = value_get_as_float (target->value);
+ x1 = value_get_as_float (target->value);
- gnm_cell_set_value (change, value_new_float (1.0));
+ gnm_cell_set_value (change, value_new_float (0));
cell_queue_recalc (change);
gnm_cell_eval (target);
- x1 = value_get_as_float (target->value);
+ x0 = value_get_as_float (target->value);
return x1 - x0;
}
@@ -481,23 +481,26 @@
for (i = ind = 0; i < param->n_total_constraints; i++) {
SolverConstraint const *c = solver_get_constraint (res, i);
GTimeVal cur_time;
- const GnmValue *val;
+ const GnmValue *lval;
+ const GnmValue *rval;
+ gnm_float lx, rx;
target = sheet_cell_get (sheet, c->lhs.col, c->lhs.row);
if (target) {
gnm_cell_eval (target);
- val = target->value;
+ lval = target->value;
} else
- val = NULL;
+ lval = NULL;
/* Check that LHS is a number type. */
- if (val == NULL || !VALUE_IS_NUMBER (val)) {
+ if (lval == NULL || !VALUE_IS_NUMBER (lval)) {
*errmsg = _("The LHS cells should contain formulas "
"that yield proper numerical values. "
"Specify valid LHS entries.");
solver_results_free (res);
return NULL;
}
+ lx = value_get_as_float (lval);
if (c->type == SolverINT) {
n = get_col_nbr (res, &c->lhs);
@@ -529,20 +532,21 @@
target = sheet_cell_get (sheet, c->rhs.col, c->rhs.row);
if (target) {
gnm_cell_eval (target);
- val = target->value;
+ rval = target->value;
} else
- val = NULL;
+ rval = NULL;
/* Check that RHS is a number type. */
- if (val == NULL || !VALUE_IS_NUMBER (val)) {
+ if (rval == NULL || !VALUE_IS_NUMBER (rval)) {
*errmsg = _("The RHS cells should contain proper "
"numerical values only. Specify valid "
"RHS entries.");
solver_results_free (res);
return NULL;
}
+ rx = value_get_as_float (rval);
- x = value_get_as_float (val);
+ x = rx - lx;
alg->set_constr_fn (program, ind, c->type, x);
res->rhs[i] = x;
ind++;
@@ -604,6 +608,8 @@
res->ilp_flag = TRUE;
}
+ alg->print_fn (program);
+
return program;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]