Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11576 - in /trunk/sat-solver/src: solver.c solver.h solverdebug.c
  • From: mlschroe@xxxxxxxxxxxxxxxx
  • Date: Tue, 04 Nov 2008 16:04:44 -0000
  • Message-id: <20081104160444.5D060473E0@xxxxxxxxxxxxxxxx>
Author: mlschroe
Date: Tue Nov 4 17:04:44 2008
New Revision: 11576

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11576&view=rev
Log:
- add support for SOLVER_ESSENTIAL flag, marks a job that has to be
fulfilled

Modified:
trunk/sat-solver/src/solver.c
trunk/sat-solver/src/solver.h
trunk/sat-solver/src/solverdebug.c

Modified: trunk/sat-solver/src/solver.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.c?rev=11576&r1=11575&r2=11576&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.c (original)
+++ trunk/sat-solver/src/solver.c Tue Nov 4 17:04:44 2008
@@ -3027,7 +3027,11 @@
else if (v > 0)
nupdate++;
else
- njob++;
+ {
+ if ((job->elements[-v -1] & SOLVER_ESSENTIAL) != 0)
+ continue; /* not that one! */
+ njob++;
+ }
queue_push(&disabled, v);
}
if (disabled.count == disabledcnt)
@@ -3111,8 +3115,13 @@

/*-------------------------------------------------------------------
* sorting helper for problems
+ *
+ * bring update rules before job rules
+ * make essential job rules last
*/

+Queue *problems_sort_data;
+
static int
problems_sortcmp(const void *ap, const void *bp)
{
@@ -3121,6 +3130,15 @@
return 1;
if (a > 0 && b < 0)
return -1;
+ if (a < 0 && b < 0)
+ {
+ Queue *job = problems_sort_data;
+ int af = job->elements[-a - 1] & SOLVER_ESSENTIAL;
+ int bf = job->elements[-a - 1] & SOLVER_ESSENTIAL;
+ int x = bf - af;
+ if (x)
+ return x;
+ }
return a - b;
}

@@ -3130,7 +3148,7 @@
*/

static void
-problems_sort(Solver *solv)
+problems_sort(Solver *solv, Queue *job)
{
int i, j;
if (!solv->problems.count)
@@ -3140,7 +3158,10 @@
if (!solv->problems.elements[i])
{
if (i > j + 1)
- qsort(solv->problems.elements + j, i - j, sizeof(Id),
problems_sortcmp);
+ {
+ problems_sort_data = job;
+ qsort(solv->problems.elements + j, i - j, sizeof(Id),
problems_sortcmp);
+ }
if (++i == solv->problems.count)
break;
j = i + 1;
@@ -3162,19 +3183,20 @@
Queue solutions;
Id *problem;
Id why;
- int i, j, nsol;
+ int i, j, nsol, probsolved;
unsigned int now, refnow;

if (!solv->problems.count)
return;
now = sat_timems(0);
- problems_sort(solv);
+ problems_sort(solv, job);
queue_clone(&problems, &solv->problems);
queue_init(&solution);
queue_init(&solutions);
/* copy over proof index */
queue_push(&solutions, problems.elements[0]);
problem = problems.elements + 1;
+ probsolved = 0;
refnow = sat_timems(0);
for (i = 1; i < problems.count; i++)
{
@@ -3192,8 +3214,15 @@
i++;
problem = problems.elements + i + 1;
refnow = sat_timems(0);
+ probsolved = 0;
continue;
}
+ if (v < 0 && (job->elements[-v - 1] & SOLVER_ESSENTIAL))
+ {
+ /* essential job, skip if we already have a solution */
+ if (probsolved)
+ continue;
+ }
refine_suggestion(solv, job, problem, v, &solution);
if (!solution.count)
continue; /* this solution didn't work out */
@@ -3260,6 +3289,7 @@
/* mark end of this solution */
if (nsol)
{
+ probsolved = 1;
queue_push(&solutions, 0);
queue_push(&solutions, 0);
}

Modified: trunk/sat-solver/src/solver.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.h?rev=11576&r1=11575&r2=11576&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.h (original)
+++ trunk/sat-solver/src/solver.h Tue Nov 4 17:04:44 2008
@@ -230,6 +230,7 @@
#define SOLVER_JOBMASK 0xff00

#define SOLVER_WEAK 0x010000
+#define SOLVER_ESSENTIAL 0x020000

/* old API compatibility, do not use in new code */
#if 1

Modified: trunk/sat-solver/src/solverdebug.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solverdebug.c?rev=11576&r1=11575&r2=11576&view=diff
==============================================================================
--- trunk/sat-solver/src/solverdebug.c (original)
+++ trunk/sat-solver/src/solverdebug.c Tue Nov 4 17:04:44 2008
@@ -463,7 +463,7 @@
if (p == 0)
{
/* job, rp is index into job queue */
- how = job->elements[rp - 1] & ~SOLVER_WEAK;
+ how = job->elements[rp - 1];
what = job->elements[rp];
select = how & SOLVER_SELECTMASK;
switch (how & SOLVER_JOBMASK)

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages