close Warning: Can't synchronize with repository "(default)" (The repository directory has changed, you should resynchronize the repository with: trac-admin $ENV repository resync '(default)'). Look in the Trac log for more information.

Changeset 3918 for branches/f4grobner


Ignore:
Timestamp:
2016-05-29T21:24:00-07:00 (8 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/pair-queue.lisp

    r3912 r3918  
    2020;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    2121
    22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    23 ;;
    24 ;; Critical pair queue implementation
    25 ;;
    26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    27 
    2822(defpackage "PAIR-QUEUE"
    2923  (:use :cl :priority-queue :monom :polynomial :utils)
    30   (:export "SUGAR-PAIR-KEY"
    31            "PAIR"
     24  (:export "PAIR"
    3225           "MAKE-PAIR"
    3326           "PAIR-FIRST"
     
    3528           "PAIR-SUGAR"
    3629           "PAIR-DIVISION-DATA"
    37            "SUGAR-ORDER"
    3830           "*PAIR-KEY-FUNCTION*"
    3931           "*PAIR-ORDER*"
     
    4537           "PAIR-QUEUE-EMPTY-P"
    4638           "SET-PAIR-HEURISTIC"
    47            ))
     39           )
     40  (:documentation "Critical pair queue implementation. The pair queue is a list of critical
     41pairs, ordered by some partial order. Pair queue is a kind of priority queue.")
     42  )
    4843           
    4944
    5045(in-package :pair-queue)
    5146
    52 (defun sugar-pair-key (p q &aux (lcm (universal-lcm (leading-monomial p) (leading-monomial q)))
    53                                 (d (sugar lcm)))
    54   "Returns list (S LCM-TOTAL-DEGREE) where S is the sugar of the S-polynomial of
    55 polynomials P and Q, and LCM-TOTAL-DEGREE is the degree of LCM(LM(P),LM(Q))."
    56   (declare (type poly p q) (type monom lcm) (type fixnum d))
    57   (cons (max
    58          (+  (- d (sugar (leading-monomial p))) (sugar p))
    59          (+  (- d (sugar (leading-monomial q))) (sugar q)))
    60         lcm))
    61 
    6247(defstruct (pair
    6348            (:constructor make-pair (first second
    6449                                           &aux
    65                                            (sugar (car (sugar-pair-key first second)))
    6650                                           (division-data nil))))
    6751  (first nil :type poly)
    6852  (second nil :type poly)
    69   (sugar 0 :type fixnum)
    7053  (division-data nil :type list))
    7154 
    72 ;;(defun pair-sugar (pair &aux (p (pair-first pair)) (q (pair-second pair)))
    73 ;;  (car (sugar-pair-key p q)))
    74 
    75 (defun sugar-order (x y)
    76   "Pair order based on sugar, ties broken by normal strategy."
    77   (declare (type cons x y))
    78   (or (< (car x) (car y))
    79       (and (= (car x) (car y))
    80            (< (total-degree (cdr x))
    81               (total-degree (cdr y))))))
    82 
    83 (defvar *pair-key-function* #'sugar-pair-key
     55(defvar *pair-key-function* nil
    8456  "Function that, given two polynomials as argument, computed the key
    8557in the pair queue.")
    8658
    87 (defvar *pair-order* #'sugar-order
     59(defvar *pair-order* nil
    8860  "Function that orders the keys of pairs.")
    8961
     
    12597to determine the priority of critical pairs in the priority queue."
    12698  (ecase method
    127     ((sugar :sugar $sugar)
    128      (setf *pair-key-function* #'sugar-pair-key
    129            *pair-order* #'sugar-order))
    130 ;     ((minimal-mock-spoly :minimal-mock-spoly $minimal_mock_spoly)
    131 ;      (setf *pair-key-function* #'mock-spoly
    132 ;          *pair-order* #'mock-spoly-order))
    13399    ((minimal-lcm :minimal-lcm $minimal_lcm)
    134100     (setf *pair-key-function* #'(lambda (p q)
Note: See TracChangeset for help on using the changeset viewer.