1. 17 Sep, 2018 1 commit
  2. 29 Jun, 2018 1 commit
  3. 24 Nov, 2017 2 commits
    • Jason Rhinelander's avatar
      New right/tolerance argument syntax; remove domain_t deduction · 6a75e5f5
      Jason Rhinelander authored
      This changes the `right` and `tolerance` argument into more complex
      objects that allow both a literal, or special objects returned by
      `search_right()`, `absolute_tolerance(.001)`, or
      `relative_tolerance(.1)`.
      
      This allows the much more descriptive syntax:
      
          constrained_maximum_search(f, 0, search_right(), relative_tolerance(.001))
      
      This also reintroduces the ability to specify an absolute tolerance
      level, which was there once (as a separate argument) but got lost along
      the way.
      
      This commit also changes the `domain_t` argument to be no longer
      deduced.  Previously it was deduced from `left`, which would have made
      the above example rather broken: `domain_t` would have been `int` (from
      the 0) rather than `double` (which would require 0.0).  Overriding
      `domain_t` now requires an explicitly template parameter:
      
          constrained_maximum_search<float>(f, 0, search_right(), relative_tolerance(.001))
      6a75e5f5
    • Jason Rhinelander's avatar
      Made readLock/writeLock arguments more generic · 512cdae1
      Jason Rhinelander authored
      This allows readLock/writeLock to take any number of arguments, where
      each argument can be a container or a member.  Previously you could
      pass a single container, or any number of members, but not combinations
      of both or multiple containers.
      512cdae1
  4. 13 Nov, 2017 4 commits
    • Jason Rhinelander's avatar
      Add output stream support for members · 7c5fb975
      Jason Rhinelander authored
      This outputs something like `Member[n]` or `Firm[n]`, and can be
      overridden on a per-subclass basis.  It also works for shared members
      and weak members.
      7c5fb975
    • Jason Rhinelander's avatar
      Dedent various header classes · 708abdc0
      Jason Rhinelander authored
      No code changes: just removing extra class body indentation and comment
      rewrapping.  Applies to:
      
      Member.hpp
      Good.hpp
      Market.hpp
      Firm.hpp
      
      There are still more left, but these in particular are changed in the
      subsequent commit.
      708abdc0
    • Jason Rhinelander's avatar
      range(): accept (code-wise) iterator pair · bba1a1d1
      Jason Rhinelander authored
      Previously `eris::range(...)` only accepted a `std::pair` argument.
      This commit adds support for also accepting a code-wise pair (e.g.
      `eris::range(it1, it2)`).
      bba1a1d1
    • Jason Rhinelander's avatar
      constrained_maximum_search fixes · 642f7423
      Jason Rhinelander authored
      - Specifying NaN for automatic `right` selection resulted in an infinite
        loop when `left` was 0.  Changed to start searching at 1.0 when that
        occurs.
      - The `constrained_minimum_search` didn't implement automatic `right`
        selection; fixed.
      - Minor tweaks to calculation to avoid promotion to double; the main
        change was introducing a `half()` function to handle division by 2
        without resorting to actual division for floating points while still
        working for non-floating point domain types.
      - Fixed a typo in the static_assert for a `bool` return type in
        `constrained_maximum_search`.
      642f7423
  5. 31 Oct, 2017 6 commits
    • Jason Rhinelander's avatar
      Clarify time_t/id_t ambiguity · a8320ac6
      Jason Rhinelander authored
      `using namespace eris;` from within a namespace doesn't resolve the
      ambiguity for `time_t`/`id_t` -- they need an explicit symbol import, or
      full qualification.
      a8320ac6
    • Jason Rhinelander's avatar
      Minor test code compilation fixes · 66b287a0
      Jason Rhinelander authored
      66b287a0
    • Jason Rhinelander's avatar
      single_peak_search - better argument type handling · 779a7ae2
      Jason Rhinelander authored
      The previous change to single_peak_search which deduced the domain type
      from the arguments was pretty undesirable: if you specified both left
      and right as integers, you'd get a search over the integer domain.
      
      This removes the type deduction, instead using an optional template
      parameter which defaults to double and isn't deduced, thus allowing
      custom types to be used, but falling back to double if not specified.
      
      This also fixes the test code to remove the tests that specified both
      relative and absolute tolerances (the latter was removed).
      779a7ae2
    • Jason Rhinelander's avatar
      Small bundle print optimization · c74adfec
      Jason Rhinelander authored
      Using a `std::set` to sort is typically less efficient than building a
      vector then sorting it (once).
      c74adfec
    • Jason Rhinelander's avatar
      De-prefix eris_id_t and eris_time_t · 4d881c7e
      Jason Rhinelander authored
      This lets external code use `eris::id_t` and `eris::time_t` which is
      far nicer than `eris::eris_id_t`.
      
      The existing `eris_id_t` and `eris_time_t` are kept as deprecated
      aliases for the new ones.
      4d881c7e
    • Jason Rhinelander's avatar
      Fix WeakMember assignment operators · e197b4ff
      Jason Rhinelander authored
      The operators weren't returning `*this`; this somehow magically worked
      properly under gcc; clang noticed and generated an illegal instruction.
      e197b4ff
  6. 28 Oct, 2017 2 commits
  7. 21 Aug, 2017 2 commits
    • Jason Rhinelander's avatar
      Allow `constrained_maximum_search` to find `right` · 83b09164
      Jason Rhinelander authored
      This adds support for automatically finding `right` based on `left`: if
      `right` is given as NaN, a search starts at `2*left` (if `left`
      positive) or `-left` (if `left` negative) and continuously doubles the
      potential `right` value until a constraint-violating value is found;
      this then forms the RHS limit.
      83b09164
    • Jason Rhinelander's avatar
      Fix pair; implement tuple; deprotect load/store · c6a2a2b7
      Jason Rhinelander authored
      - std::pair was missing a load_from/store_to implementation
      - reimplemented std::pair support as std::tuple support, with std::pair
        being just a specialization of the tuple serializer.
      - De-protected load_from/store_to; they require friend classes all over
        the place because they aren't really "protected".
      - remove serializer.cpp in favour of just inlining its three small
        functions in the .hpp.
      c6a2a2b7
  8. 06 Aug, 2017 2 commits
    • Jason Rhinelander's avatar
      algorithms: add a constrained_{max,min}imum_search · 33e11b3a
      Jason Rhinelander authored
      This lets you numerically find the largest or smallest value satisfying
      some condition.
      
      For example, to determine the highest price that has at least `x` sales:
      
          auto quantity_demanded = [](double p) { return (int)(99 - 2*p); };
          int x = 10;
          double min = 0.0, max = 100.0;
          auto r = eris::constrained_maximum_search(
              [&](double p) { return quantity_demanded(p) >= x; },
              min, max, 0 /* maximum precision */);
          std::cout << std::setprecision(16) << "p = " << r.arg << "\n";
          // p = 44.5
      
      With less precision for `tol_rel` (e.g. the default, 1e-10) you'll
      generally get some number slightly smaller than 44.5.
      33e11b3a
    • Jason Rhinelander's avatar
      Make single_peak_search templated; remove abs_tol · 2bf6d8d3
      Jason Rhinelander authored
      This makes single_peak_search templated (so that it doesn't have to be
      implemented with double).  It also updates the return type struct with
      templated types, a constructor, and an iterator counter.
      2bf6d8d3
  9. 22 Jun, 2017 1 commit
  10. 21 Jun, 2017 1 commit
    • Jason Rhinelander's avatar
      Use a C++14 std::shared_timed_mutex for locking · 7df75988
      Jason Rhinelander authored
      This significantly simplifies the member locking implementation since we
      no longer have to worry about tracking the number of active locks;
      instead read locks are shared locks and write locks are exclusive locks;
      the stl implementation can worry about the details beyond that.
      
      This also disallows recursive member locks; instead calling code has to
      manage itself to avoid double-locking a member.  Note also that
      switching a write lock to a read lock is no longer guaranteed to be
      non-blocking as there is no way to downgrade an exclusive lock to a
      shared lock.  boost::upgrade_mutex could allow this, but this importance
      of this is minor and it seems nicer to get rid of the boost dependency.
      
      It also changes the main Simulation run lock to be the same stl
      implementation; previously it was using the boost implementation.
      
      With that, the boost thread, date_time, and atomic library components
      are no longer required.
      7df75988
  11. 20 Jun, 2017 1 commit
  12. 26 May, 2017 1 commit
    • Jason Rhinelander's avatar
      Callbacks: support priority, simplify implementation · 72031ec7
      Jason Rhinelander authored
      Add a second parameter (priority) to the callback constructors and
      provide an override for the associated priority.
      
      This also simplifies the structure by moving the constructors and
      function/priority storage into a common base class.
      
      Everything also gets inlined as every method here is extremely simple.
      72031ec7
  13. 24 May, 2017 1 commit
  14. 23 May, 2017 15 commits