Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag algebra implementation #36908

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open

Commits on Dec 17, 2023

  1. Flag algebra implementation

    Can handle any theory, any signature. A few interesting theories are included:
    -Graphs
    -Digraphs
    -Hypergrpahs
    -Graphs for Ramsey theory
    -Tournaments
    -Graphs with ordered edges
    -Graphs with ordered vertices
    
    It is designed to fit in the sage structure, FlagAlgebras can be constructed over any base ring containing QQ, and over any such combinatorial theory (graphs, hypergraphs etc). FlagAlgebraElements can be added and multiplied together interactively, with good performance and the powerful coercion model. Flag algebraic optimization problems can be solved with a small csdp wrapper csdpy (only working with linux at the moment).
    
    Includes docstring with examples, all finishing successfully.
    
    There is a small change to coerce.pyx to ask if the elements prefer a different form before applying an operation (so Flag is treated as a FlagAlgebraElement).
    bodnalev committed Dec 17, 2023
    Configuration menu
    Copy the full SHA
    55c3314 View commit details
    Browse the repository at this point in the history

Commits on Dec 18, 2023

  1. Added references

    Added references to the bibliography and from other points of sage to flag algebras.
    bodnalev committed Dec 18, 2023
    Configuration menu
    Copy the full SHA
    dca0105 View commit details
    Browse the repository at this point in the history

Commits on Jan 3, 2024

  1. sync with official remote (#1)

    * build/pkgs/referencing/dependencies: Add missing dep
    
    * add :wikipedia:`Cycle Index Theorem etc
    
    as explained in my comments on the PR
    
    * Fixes for reviewer comments
    
    * fix linter
    
    * Implement fallback mechanism of default latex engine
    
    * fix qepcad doctest
    
    This test started to fail on Sage 10.3.beta2
    
    * Small edit
    
    * adding line breaks ad suggested
    
    * fix doctest warnings in src/sage/interfaces/
    
    * some ruff fixes (UP034 and UP039 codes) and error links in categories
    
    * ruff auto-fixing several details in combinat folder
    
    * more fixes
    
    * some ruff fixes and error links in the graphs folder
    
    * removed 'arb' which popped up in deps
    
    * sage.env, sage.misc.package: Use SAGE_LOCAL_SPKG_INST to avoid clash with SAGE_SPKG_INST set by sage-spkg
    
    * fix warnings in coxeter_group.py
    
    * fix warnings in coxeter_group.py
    
    * Default engine is computed lazily
    
    * fix warnings in coxeter.pyx
    
    * fix doctest warnings in src/sage/game_theory/gambit_docs.py
    
    * fix doctest warnings in src/sage/game_theory/parser.py
    
    * ruff UP details and links to errors in doc in geometry folder
    
    * fix doctest warnings in src/sage/game_theory/normal_form_game.py
    
    * document&test corner case, empty domain without constraints
    
    * Documented that sagemath#36527 causes erroneous results & how to avoid
    
    * fix doctest warnings in src/sage/categories/finite_complex_reflection_groups.py
    
    * fix doctest warnings in src/sage/coding/ag_code_decoders.pyx
    
    * fix doctest warnings in src/sage/plot/graphics.py
    
    * oops, correct workaround
    
    * fix doctest warnings in src/sage/quadratic_forms/ternary_qf
    
    * various fixes in quadratic_forms (ruff, pep8, error links, etc)
    
    * Small language fixes; for brevity move one example to tests
    
    * png() uses the default engine
    
    * suggested details
    
    * suggested details
    
    * Changed _matrix_power_symbolic function to condier mk=0 case
    
    This fixes sagemath#36838. Here, I have added a condition to check whether
    mk=0 or not. Because whenever mk=0 we should give mk^(n-i) (i.e. 0^(n-i))
    instead of only 0 considering (n-i) can be equal to zero and in this
    case 0^(n-i) will be more accurate than only 0.
    
    * Changed the _matrix_power_symbolic function to handle all the cases
    
    This change handles all the errors which were occuring in previous
    commit and this commit handles the case of mx=0 very effectively.
    
    * Created tests covering the changes
    
    Created tests covering the changes and checking whether the
    trac:`36838` is fixed or not.
    
    * Give more precise answer by using kroncker_delta function
    
    Instead of returning 0^(n-i), it would be more precise if
    we reutrn value of  kroncker_delta function, it will be helpful when
    we try to evaluate the final matrix using the value of n.
    
    * Rewriting tests for the PR
    
    Changed the final answer given by test of this PR.
    
    * Correct answers of the doctest for _matrix_power_symbolic function
    
    Changed the answer of doctest  according to new changes.
    
    * Corrected the doctest
    
    Corrected the doctest and improved some code styles, which were not
    correct according to guidelines for python coding for sage.
    
    * Modified the doctest and changed the comment
    
    Updated the old doctests which were failing before and updated the comment
    to make it more readable.
    
    * Corrected lint errors
    
    * use file-level tag in src/sage/libs/coxeter/coxeter.pyx
    
    * use file-level tag in src/sage/libs/coxeter/coxeter_group.py
    
    * build/pkgs/*/distros: Remove quotes, change to one package per line
    
    git grep -l \" build/pkgs/*/distros* | xargs sed -i.bak '/^"/s/"//g'
    
    git grep -l -E '^([^# ]+) +([^# ][^#]+)(#.*)' build/pkgs/*/distros/*.txt | xargs sed -E -i.bak $'s/^([^# ]+) +([^# ][^#]+)(#.*)?/\\3\\\n\\1\\\n\\2/'
    
    git grep -l -E '^([^# ]+) +([^# ][^#]+)' build/pkgs/*/distros/*.txt | xargs sed -E -i.bak $'s/^([^# ]+) +([^# ][^#]+)/\\1\\\n\\2/'
    
    git grep -l -E ' +$' build/pkgs/*/distros/*.txt | xargs sed -E -i.bak 's/[ ]+$//'
    
    * build/bin/sage-print-system-package-command: Shell-quote the packages
    
    * fix precision issue for 𝑗=0 and ℓ=3
    
    * build/bin/sage-get-system-packages: Substitute PYTHON_MINOR here
    
    * build/bin/write-dockerfile.sh: Shell-quote system packages
    
    * src/doc/bootstrap: Use sage-get-system-packages so that ENABLE_SYSTEM_SITEPACKAGES is respected
    
    * sage-spkg-info, src/doc/bootstrap: Wrap command lines
    
    * Current engine is dependent on the user's system
    
    * Document the format of system package files
    
    * src/doc/bootstrap: Wrap more narrowly
    
    * Addressing reviewer comments.
    
    * build/bin/sage-print-system-package-command: Simplify
    
    * src/doc/bootstrap: Remove unused variable
    
    * src/doc/bootstrap: Parallelize generation of SPKG.rst files
    
    * build/bin/sage-spkg-info: Restore lost blank output line
    
    * build/bin/sage-spkg-info: Fix and improve RST markup
    
    * 36884: issue reference
    
    Co-authored-by: Travis Scrimshaw <[email protected]>
    
    * 36884: doctest formatting
    
    Co-authored-by: Travis Scrimshaw <[email protected]>
    
    * 36884: replace copy
    
    Co-authored-by: Travis Scrimshaw <[email protected]>
    
    * adding corolla-related methods to free pre-Lie algebras
    
    * 36884: new list loop_crossings
    
    * build/pkgs/_bootstrap/distros/fedora.txt: Remove outdated comment
    
    * tox.ini: Add local-macports
    
    * Add macports.txt
    
    * build/pkgs/_prereq/distros: Update file comments
    
    * build/bin/sage-print-system-package-command: Handle macports install
    
    * tox.ini (local-macports-optlocal): Use sudo
    
    * build/bin/sage-print-system-package-command (macports): Handle setup-build-env
    
    * build/bin/sage-guess-package-system: Detect macports
    
    * tox.ini: Add configuration factors macports-python{3.8,3.9}
    
    * build/bin/sage-print-system-package-command (macports): Recommend FC as configure arg, not environment variable
    
    This is so that the presence of the environment variable at 'make' time
    does not break the build when the compiler is not actually present.
    
    * tox.ini (macports): Pass FC as configure argument; add variants macports-gcc_{spkg,9,10,11}
    
    * tox.ini (macports): Fix up use of ALL_EXTRA_SAGE_PACKAGES
    
    * tox.ini (local-macports): Update macports base version to 2.7.2
    
    * build/pkgs/gfortran/distros/macports.txt: Switch to gcc11
    
    * tox.ini (macports): By default use FC=gfortran-mp-11
    
    * build/bin/sage-print-system-package-command (macports): Also update to gcc11 here
    
    * WIP
    
    * tox.ini (macports): Remove variants that tried to use real gcc
    
    * build/pkgs/libgd/distros/macports.txt: Disable
    
    * build/pkgs/python3/distros/macports.txt: Use python310
    
    * Disable more broken macports packages
    
    * build/bin/sage-print-system-package-command [macports]: Do not describe variants that do not work
    
    * tox.ini (macports): Set CPATH, LIBRARY_PATH
    
    * build/pkgs/pari/distros/macports.txt: Disable
    
    * tox.ini (macports): Use isysroot
    
    * build/bin/sage-print-system-package-command (macports): Update use of print_shell_command
    
    * build/pkgs/_bootstrap/distros/macports.txt: One package per line
    
    * tox.ini: Add macports-python3.12
    
    * revert some "a -> an" changes
    
    * Updated SageMath version to 10.3.beta3
    
    * Remove a redundant comment
    
    * build/pkgs/e_antic: Update to 2.0.0
    
    * sage.{coding,combinat}: Update # needs
    
    * sage.combinat.root_system: Update # needs
    
    * sage.combinat: Update # needs
    
    * sage.combinat: Update # needs
    
    * sage -fixdoctests src/sage/combinat
    
    * sage.rings: Update # needs
    
    * sage.rings: Update # needs
    
    * sage.rings: Update # needs
    
    * sage -fixdoctests src/sage/rings
    
    * src/sage/rings/power_series_ring.py: Fix import
    
    * Remove empty doctest lines
    
    * sage.rings: Break an import cycle
    
    * sage.rings.continued_fraction: Make imports from sage.combinat.words lazy
    
    * sage.{categories,rings}: Modularization fixes for imports
    
    * Remove uses of sage.PACKAGE.all...
    
    * pkgs/sagemath-{flint,symbolics}: Fixups
    
    * Massive modularization fixes
    
    * Remove uses of sage.PACKAGE.all... (fixup)
    
    * pkgs/sagemath-gap: Move reflection_group, weyl_group here from sagemath-modules
    
    * suggested changes, arigato !
    
    * refresh the doc about coercion and test the given example
    
    * reverted changes and added self.is_dead(warn_only=True)
    
    * fixing one bug in the use of valuation
    
    * suggested detail
    
    * add interface to nauty's genktreeg
    
    * 36884: treat no loops first
    
    Co-authored-by: Travis Scrimshaw <[email protected]>
    
    * src/sage/calculus/ode.pyx: constness fix for clang 16
    
    * sage.rings: Modularization fixes for imports of power series
    
    * build/pkgs/normaliz/patches: Add https://github.com/Normaliz/Normaliz/issues/412\#issuecomment-1862036237
    
    * src/sage/rings/finite_rings/element_ntl_gf2e.pyx: Fix test for libgap element
    
    * Fixing some details.
    
    * build/pkgs/normaliz/spkg-install.in: Override FLINT configure test
    
    * build/pkgs/_prereq/distros/conda.txt: Pin compilers until sagemath#36840 is fixed
    
    * build/pkgs/{normaliz,pynormaliz}: Add patchlevel to trigger build of pynormaliz in 'CI Linux incremental'
    
    * change build/pkgs/nauty/spkg-configure.m4
    
    * details fixed in cfinite_sequence.py
    
    * update comment in build/pkgs/nauty/spkg-configure.m4
    
    * src/sage/tests/gap_packages.py: Normalize package names to lower case in doctest
    
    * suggested changes
    
    * build/pkgs/furo/spkg-install.in: Remove
    
    * remove one doctest, fix the other
    
    * add some # optional - nauty tags
    
    * some details in multi_polynomial base
    
    * use # needs nauty
    
    * suggested change in src/sage/features/nauty.py
    
    * src/sage/doctest/forker.py: Use JobClient(use_cysignals=True)
    
    * src/sage/doctest/forker.py: Do not mask ImportError while calling JobClient
    
    * build/pkgs/gnumake_tokenpool: Update to 0.0.4
    
    * build/pkgs/gnumake_tokenpool/install-requires.txt: require >= 0.0.4
    
    * sage.plot: Update # needs
    
    * sage.plot: Update # needs
    
    * Add # needs
    
    * sage -fixdoctests src/sage/plot
    
    * src/sage/plot/arc.py: Fix # needs
    
    * sage.plot: Doctest cosmetics (copied from sagemath#35095)
    
    * src/sage/plot/plot3d/list_plot3d.py: Fix up
    
    * src/sage/misc/replace_dot_all.py: Update doctest output
    
    * src/sage/plot/plot.py: Fix Warning: Variable 'x' referenced here was set only in doctest marked '# long time, needs sage.symbolic'
    
    * src/sage/doctest/sources.py: Use file-level doctest tags for the virtual doctest; fixes Warning: Variable 'sig_on_count' referenced here was set only ...
    
    * build/pkgs/ninja_build: support samurai version scheme
    
    Samurai is a C99 ninja implementation with an almost-compatible
    version scheme, except that it has only two version components
    instead of the three that ninja has. We update the "sed" call
    used to parse the version number out of `ninja --version` so
    that it can parse a samurai version too.
    
    This should only matter on systems where (for example) /usr/bin/ninja
    points to samurai. That's not typical, but it recently became possible
    to do on Gentoo in an "official" way.
    
    * src/sage/combinat/permutation.py: Fix # needs
    
    * src/sage/combinat/root_system/non_symmetric_macdonald_polynomials.py: Fix # needs
    
    * Addressing review comments for detecting subtypes.
    
    * Updated SageMath version to 10.3.beta4
    
    ---------
    
    Co-authored-by: Matthias Koeppe <[email protected]>
    Co-authored-by: Dima Pasechnik <[email protected]>
    Co-authored-by: Kwankyu Lee <[email protected]>
    Co-authored-by: Frédéric Chapoton <[email protected]>
    Co-authored-by: dcoudert <[email protected]>
    Co-authored-by: Jukka Kohonen <[email protected]>
    Co-authored-by: RuchitJagodara <[email protected]>
    Co-authored-by: Release Manager <[email protected]>
    Co-authored-by: Lorenz Panny <[email protected]>
    Co-authored-by: Travis Scrimshaw <[email protected]>
    Co-authored-by: Sebastian Oehms <[email protected]>
    Co-authored-by: Travis Scrimshaw <[email protected]>
    Co-authored-by: Sebastian <[email protected]>
    Co-authored-by: John Cremona <[email protected]>
    Co-authored-by: Heiko Knospe <[email protected]>
    Co-authored-by: adrinospy <[email protected]>
    Co-authored-by: Tobias Diez <[email protected]>
    Co-authored-by: Michael Orlitzky <[email protected]>
    19 people authored Jan 3, 2024
    Configuration menu
    Copy the full SHA
    121b7ff View commit details
    Browse the repository at this point in the history

Commits on Feb 29, 2024

  1. Reply to 36908#issuecomment-1862306436

    reply to commit:
    
    - I've added an extra link to Razborov's Flag Algebras paper, from the Flag
    file. I can attempt a greater explanation of what is happening there, but the
    paper's terminology is followed. The novelty is CombinatorialTheory, which
    comes with a detailed docstring.
    
    - The reason I changed coerce is the following:
        CombinatorialTheory is a parent, the elements are Flag-s.
        FlagAlgebra is a parent, the elements are FlagAlgebraElement-s.
        But a CombinatorialTheory contains all Flag-s, with every ftype, while a
        FlagAlgebra is only defined over a fixed ftype.
    
        But Flag-s, with a fixed ftype, form a basis for the FlagAlgebra with the
        same ftype. Therefore it makes sense to add and multiply the Flag-s together
        without the annoying step between, to change them to FlagAlgebraElement-s and
        then do the operation.
    
        As I was looking at the coercion model, I couldn't find a way to define coercion
        that depends on the elements. It wouldn't really make sense anyway. But when
        evaluating an expression like `Flag + Integer`, just from the parents,
        (CombinatorialTheory, Integers) it is impossible to figure out which FlagAlgebra
        they land in, since it depends on the Flag's ftype.
    
        So the extra code I added to the coercion is something really simple.
        It asks the operands (like the Flag in this example)
        if there is a form that actually behaves like an operand. And if they have
        a better form (Flag turns to FlagAlgebraElement) then use that better form
        in the operation.
    
        The code comes after all the other steps, so after the failure of all the
        other coercion attempts. If the `as_operand` is not implemented, then it acts
        just like the previous code, and there is only an overhead when an error occurs
        (which I assumed is fine since something went wrong anyway).
    
        I can add this to a separate PR. But the change only makes sense here, when I
        want to use this. I can add this explanation somewhere, if that helps.
    
    - All private functions should have tests now
    
    - I've experimented with that, but most of the heavy lifting is happening in Flag,
    I didn't see a reason to switch.
    
    - Thank you for catching those, I think I'm using the catalogs properly now,
    let me know if they are still bad. Also replaced `== None` with `is None`
    
    - I still can't build the reference manual. `make docbuild` gives this error:
    
    ```
    The following package(s) may have failed to build (not necessarily
    during this run of 'make docbuild'):
    
    * package:         sagemath_doc_html-none
      last build time: Dec 20 11:44
      log file:        /home/bodnalev/sage/logs/pkgs/sagemath_doc_html-none.log
      build directory: /home/bodnalev/sage/local/var/tmp/sage/build/sagemath_doc_html-none
    ```
    
    - Made small fixes in the documentation
    bodnalev committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    6c43a7b View commit details
    Browse the repository at this point in the history
  2. cvxopt change

    bodnalev committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    f95f450 View commit details
    Browse the repository at this point in the history
  3. Some docstring update

    bodnalev committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    a61e9c3 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2024

  1. Configuration menu
    Copy the full SHA
    632ace7 View commit details
    Browse the repository at this point in the history

Commits on Jun 13, 2024

  1. auto saving calculations

    bodnalev committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    a6c5d8a View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2024

  1. primal dual correction

    bodnalev committed Jun 20, 2024
    Configuration menu
    Copy the full SHA
    59860ba View commit details
    Browse the repository at this point in the history
  2. optimize quotients

    bodnalev committed Jun 20, 2024
    Configuration menu
    Copy the full SHA
    cd5f07d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7368bf0 View commit details
    Browse the repository at this point in the history

Commits on Jun 22, 2024

  1. Configuration menu
    Copy the full SHA
    e308641 View commit details
    Browse the repository at this point in the history

Commits on Jun 26, 2024

  1. Configuration menu
    Copy the full SHA
    8ddbf7d View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2024

  1. Configuration menu
    Copy the full SHA
    290dea8 View commit details
    Browse the repository at this point in the history

Commits on Jul 16, 2024

  1. weak equality

    and clear code fix
    bodnalev committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    ff73d79 View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2024

  1. sparse vectors

    bodnalev committed Jul 19, 2024
    Configuration menu
    Copy the full SHA
    c1acf8a View commit details
    Browse the repository at this point in the history

Commits on Jul 30, 2024

  1. better save

    bodnalev committed Jul 30, 2024
    Configuration menu
    Copy the full SHA
    c0e12b6 View commit details
    Browse the repository at this point in the history

Commits on Aug 20, 2024

  1. Configuration menu
    Copy the full SHA
    d128280 View commit details
    Browse the repository at this point in the history
  2. small fix

    bodnalev committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    978b4a6 View commit details
    Browse the repository at this point in the history

Commits on Aug 21, 2024

  1. Configuration menu
    Copy the full SHA
    80144b6 View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2024

  1. more robust rounding

    bodnalev committed Aug 22, 2024
    Configuration menu
    Copy the full SHA
    cabae26 View commit details
    Browse the repository at this point in the history

Commits on Aug 26, 2024

  1. Configuration menu
    Copy the full SHA
    dd8fce8 View commit details
    Browse the repository at this point in the history

Commits on Aug 28, 2024

  1. Configuration menu
    Copy the full SHA
    9e044c1 View commit details
    Browse the repository at this point in the history
  2. save load bugfix

    bodnalev committed Aug 28, 2024
    Configuration menu
    Copy the full SHA
    ba7f8a4 View commit details
    Browse the repository at this point in the history

Commits on Sep 24, 2024

  1. certificate verifier

    output of the certificate is now in the original base
    
    verifier depends on only a small part of the code now.
    bodnalev committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    52175f6 View commit details
    Browse the repository at this point in the history

Commits on Sep 26, 2024

  1. no phi rounding fixes

    bodnalev committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    6eb34e4 View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2024

  1. Can do non-exact rounding

    With the X + epsilon I method
    bodnalev committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    c25c796 View commit details
    Browse the repository at this point in the history

Commits on Oct 2, 2024

  1. saving certificates to files

    also bugs with typed optimization's rounding are fixed
    bodnalev committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    cc6233a View commit details
    Browse the repository at this point in the history
  2. pickle certificates

    and debug info for the exact rounding too
    bodnalev committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    6c4bcf6 View commit details
    Browse the repository at this point in the history

Commits on Oct 4, 2024

  1. Update flag_algebras.py

    bodnalev committed Oct 4, 2024
    Configuration menu
    Copy the full SHA
    ed576fa View commit details
    Browse the repository at this point in the history

Commits on Oct 9, 2024

  1. Update flag_algebras.py

    bodnalev committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    7ebef8a View commit details
    Browse the repository at this point in the history