From ea3aa6098cb6749078b10859f1b722f20cae9598 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 8 Nov 2023 14:49:54 +0100 Subject: [PATCH] different writer types --- ...oh.iohcpp.logger.property.CURRENTBESTY.rst | 19 +- .../ioh.iohcpp.logger.property.CURRENTY.rst | 19 +- ...ioh.iohcpp.logger.property.EVALUATIONS.rst | 19 +- .../ioh.iohcpp.logger.property.PENALTY.rst | 19 +- .../api/ioh.iohcpp.logger.property.RAWY.rst | 19 +- .../ioh.iohcpp.logger.property.RAWYBEST.rst | 19 +- ...oh.iohcpp.logger.property.TRANSFORMEDY.rst | 19 +- ...ohcpp.logger.property.TRANSFORMEDYBEST.rst | 19 +- .../ioh.iohcpp.logger.property.VIOLATION.rst | 19 +- ...ohcpp.logger.property.CURRENTBESTY.rst.txt | 19 +- ...oh.iohcpp.logger.property.CURRENTY.rst.txt | 19 +- ...iohcpp.logger.property.EVALUATIONS.rst.txt | 19 +- ...ioh.iohcpp.logger.property.PENALTY.rst.txt | 19 +- .../ioh.iohcpp.logger.property.RAWY.rst.txt | 19 +- ...oh.iohcpp.logger.property.RAWYBEST.rst.txt | 19 +- ...ohcpp.logger.property.TRANSFORMEDY.rst.txt | 19 +- ...p.logger.property.TRANSFORMEDYBEST.rst.txt | 19 +- ...h.iohcpp.logger.property.VIOLATION.rst.txt | 19 +- ....iohcpp.problem.GriewankRosenBrock.rst.txt | 34 +-- ...h.iohcpp.logger.property.CURRENTBESTY.html | 58 +++- .../ioh.iohcpp.logger.property.CURRENTY.html | 58 +++- ...oh.iohcpp.logger.property.EVALUATIONS.html | 58 +++- .../ioh.iohcpp.logger.property.PENALTY.html | 58 +++- docs/api/ioh.iohcpp.logger.property.RAWY.html | 58 +++- .../ioh.iohcpp.logger.property.RAWYBEST.html | 58 +++- ...h.iohcpp.logger.property.TRANSFORMEDY.html | 58 +++- ...hcpp.logger.property.TRANSFORMEDYBEST.html | 58 +++- .../ioh.iohcpp.logger.property.VIOLATION.html | 58 +++- ...ioh.iohcpp.problem.GriewankRosenBrock.html | 259 ++++++++---------- include/ioh/common/file.hpp | 146 +++++++--- include/ioh/logger/flatfile.hpp | 12 +- ioh/src/logger.cpp | 21 ++ tests/cpp/logger/test_flatfile.cpp | 31 ++- 33 files changed, 1018 insertions(+), 349 deletions(-) diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.CURRENTBESTY.rst b/doc/python/source/api/ioh.iohcpp.logger.property.CURRENTBESTY.rst index 1524b5054..69e00a6ce 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.CURRENTBESTY.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.CURRENTBESTY.rst @@ -1,6 +1,21 @@ -CURRENTBESTY +CurrentBestY ============ .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: CURRENTBESTY +.. autoclass:: CurrentBestY + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~CurrentBestY.__call__ + ~CurrentBestY.call_to_string + ~CurrentBestY.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.CURRENTY.rst b/doc/python/source/api/ioh.iohcpp.logger.property.CURRENTY.rst index 17dde09eb..3f5d64b23 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.CURRENTY.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.CURRENTY.rst @@ -1,6 +1,21 @@ -CURRENTY +CurrentY ======== .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: CURRENTY +.. autoclass:: CurrentY + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~CurrentY.__call__ + ~CurrentY.call_to_string + ~CurrentY.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.EVALUATIONS.rst b/doc/python/source/api/ioh.iohcpp.logger.property.EVALUATIONS.rst index c25c536d4..de2fbdd26 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.EVALUATIONS.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.EVALUATIONS.rst @@ -1,6 +1,21 @@ -EVALUATIONS +Evaluations =========== .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: EVALUATIONS +.. autoclass:: Evaluations + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Evaluations.__call__ + ~Evaluations.call_to_string + ~Evaluations.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.PENALTY.rst b/doc/python/source/api/ioh.iohcpp.logger.property.PENALTY.rst index f38e64091..33fcb0128 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.PENALTY.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.PENALTY.rst @@ -1,6 +1,21 @@ -PENALTY +Penalty ======= .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: PENALTY +.. autoclass:: Penalty + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Penalty.__call__ + ~Penalty.call_to_string + ~Penalty.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.RAWY.rst b/doc/python/source/api/ioh.iohcpp.logger.property.RAWY.rst index 735fedf70..0712d9a73 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.RAWY.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.RAWY.rst @@ -1,6 +1,21 @@ -RAWY +RawY ==== .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: RAWY +.. autoclass:: RawY + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~RawY.__call__ + ~RawY.call_to_string + ~RawY.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.RAWYBEST.rst b/doc/python/source/api/ioh.iohcpp.logger.property.RAWYBEST.rst index 35a915584..8d2a3b25d 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.RAWYBEST.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.RAWYBEST.rst @@ -1,6 +1,21 @@ -RAWYBEST +RawYBest ======== .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: RAWYBEST +.. autoclass:: RawYBest + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~RawYBest.__call__ + ~RawYBest.call_to_string + ~RawYBest.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.TRANSFORMEDY.rst b/doc/python/source/api/ioh.iohcpp.logger.property.TRANSFORMEDY.rst index 8b51f4b43..207e17b4a 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.TRANSFORMEDY.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.TRANSFORMEDY.rst @@ -1,6 +1,21 @@ -TRANSFORMEDY +TransformedY ============ .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: TRANSFORMEDY +.. autoclass:: TransformedY + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~TransformedY.__call__ + ~TransformedY.call_to_string + ~TransformedY.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.rst b/doc/python/source/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.rst index 9478f7574..98c735a9b 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.rst @@ -1,6 +1,21 @@ -TRANSFORMEDYBEST +TransformedYBest ================ .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: TRANSFORMEDYBEST +.. autoclass:: TransformedYBest + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~TransformedYBest.__call__ + ~TransformedYBest.call_to_string + ~TransformedYBest.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/doc/python/source/api/ioh.iohcpp.logger.property.VIOLATION.rst b/doc/python/source/api/ioh.iohcpp.logger.property.VIOLATION.rst index db96f4cc7..7eb56d099 100644 --- a/doc/python/source/api/ioh.iohcpp.logger.property.VIOLATION.rst +++ b/doc/python/source/api/ioh.iohcpp.logger.property.VIOLATION.rst @@ -1,6 +1,21 @@ -VIOLATION +Violation ========= .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: VIOLATION +.. autoclass:: Violation + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Violation.__call__ + ~Violation.call_to_string + ~Violation.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.CURRENTBESTY.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.CURRENTBESTY.rst.txt index 1524b5054..69e00a6ce 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.CURRENTBESTY.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.CURRENTBESTY.rst.txt @@ -1,6 +1,21 @@ -CURRENTBESTY +CurrentBestY ============ .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: CURRENTBESTY +.. autoclass:: CurrentBestY + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~CurrentBestY.__call__ + ~CurrentBestY.call_to_string + ~CurrentBestY.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.CURRENTY.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.CURRENTY.rst.txt index 17dde09eb..3f5d64b23 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.CURRENTY.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.CURRENTY.rst.txt @@ -1,6 +1,21 @@ -CURRENTY +CurrentY ======== .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: CURRENTY +.. autoclass:: CurrentY + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~CurrentY.__call__ + ~CurrentY.call_to_string + ~CurrentY.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.EVALUATIONS.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.EVALUATIONS.rst.txt index c25c536d4..de2fbdd26 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.EVALUATIONS.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.EVALUATIONS.rst.txt @@ -1,6 +1,21 @@ -EVALUATIONS +Evaluations =========== .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: EVALUATIONS +.. autoclass:: Evaluations + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Evaluations.__call__ + ~Evaluations.call_to_string + ~Evaluations.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.PENALTY.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.PENALTY.rst.txt index f38e64091..33fcb0128 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.PENALTY.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.PENALTY.rst.txt @@ -1,6 +1,21 @@ -PENALTY +Penalty ======= .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: PENALTY +.. autoclass:: Penalty + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Penalty.__call__ + ~Penalty.call_to_string + ~Penalty.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.RAWY.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.RAWY.rst.txt index 735fedf70..0712d9a73 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.RAWY.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.RAWY.rst.txt @@ -1,6 +1,21 @@ -RAWY +RawY ==== .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: RAWY +.. autoclass:: RawY + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~RawY.__call__ + ~RawY.call_to_string + ~RawY.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.RAWYBEST.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.RAWYBEST.rst.txt index 35a915584..8d2a3b25d 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.RAWYBEST.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.RAWYBEST.rst.txt @@ -1,6 +1,21 @@ -RAWYBEST +RawYBest ======== .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: RAWYBEST +.. autoclass:: RawYBest + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~RawYBest.__call__ + ~RawYBest.call_to_string + ~RawYBest.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.TRANSFORMEDY.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.TRANSFORMEDY.rst.txt index 8b51f4b43..207e17b4a 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.TRANSFORMEDY.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.TRANSFORMEDY.rst.txt @@ -1,6 +1,21 @@ -TRANSFORMEDY +TransformedY ============ .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: TRANSFORMEDY +.. autoclass:: TransformedY + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~TransformedY.__call__ + ~TransformedY.call_to_string + ~TransformedY.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.rst.txt index 9478f7574..98c735a9b 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.rst.txt @@ -1,6 +1,21 @@ -TRANSFORMEDYBEST +TransformedYBest ================ .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: TRANSFORMEDYBEST +.. autoclass:: TransformedYBest + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~TransformedYBest.__call__ + ~TransformedYBest.call_to_string + ~TransformedYBest.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.logger.property.VIOLATION.rst.txt b/docs/_sources/api/ioh.iohcpp.logger.property.VIOLATION.rst.txt index db96f4cc7..7eb56d099 100644 --- a/docs/_sources/api/ioh.iohcpp.logger.property.VIOLATION.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.logger.property.VIOLATION.rst.txt @@ -1,6 +1,21 @@ -VIOLATION +Violation ========= .. currentmodule:: ioh.iohcpp.logger.property -.. autodata:: VIOLATION +.. autoclass:: Violation + :show-inheritance: + + .. rubric:: Methods Summary + + .. autosummary:: + + ~Violation.__call__ + ~Violation.call_to_string + ~Violation.name + + .. rubric:: Methods Documentation + + .. automethod:: __call__ + .. automethod:: call_to_string + .. automethod:: name diff --git a/docs/_sources/api/ioh.iohcpp.problem.GriewankRosenBrock.rst.txt b/docs/_sources/api/ioh.iohcpp.problem.GriewankRosenBrock.rst.txt index 66a8010ef..4fee0c14f 100644 --- a/docs/_sources/api/ioh.iohcpp.problem.GriewankRosenBrock.rst.txt +++ b/docs/_sources/api/ioh.iohcpp.problem.GriewankRosenBrock.rst.txt @@ -1,35 +1,35 @@ -GriewankRosenBrock +GriewankRosenbrock ================== .. currentmodule:: ioh.iohcpp.problem -.. autoclass:: GriewankRosenBrock +.. autoclass:: GriewankRosenbrock :show-inheritance: .. rubric:: Attributes Summary .. autosummary:: - ~GriewankRosenBrock.bounds - ~GriewankRosenBrock.constraints - ~GriewankRosenBrock.log_info - ~GriewankRosenBrock.meta_data - ~GriewankRosenBrock.optimum - ~GriewankRosenBrock.problems - ~GriewankRosenBrock.state + ~GriewankRosenbrock.bounds + ~GriewankRosenbrock.constraints + ~GriewankRosenbrock.log_info + ~GriewankRosenbrock.meta_data + ~GriewankRosenbrock.optimum + ~GriewankRosenbrock.problems + ~GriewankRosenbrock.state .. rubric:: Methods Summary .. autosummary:: - ~GriewankRosenBrock.__call__ - ~GriewankRosenBrock.add_constraint - ~GriewankRosenBrock.attach_logger - ~GriewankRosenBrock.create - ~GriewankRosenBrock.detach_logger - ~GriewankRosenBrock.enforce_bounds - ~GriewankRosenBrock.remove_constraint - ~GriewankRosenBrock.reset + ~GriewankRosenbrock.__call__ + ~GriewankRosenbrock.add_constraint + ~GriewankRosenbrock.attach_logger + ~GriewankRosenbrock.create + ~GriewankRosenbrock.detach_logger + ~GriewankRosenbrock.enforce_bounds + ~GriewankRosenbrock.remove_constraint + ~GriewankRosenbrock.reset .. rubric:: Attributes Documentation diff --git a/docs/api/ioh.iohcpp.logger.property.CURRENTBESTY.html b/docs/api/ioh.iohcpp.logger.property.CURRENTBESTY.html index 5171017fd..9701a4ada 100644 --- a/docs/api/ioh.iohcpp.logger.property.CURRENTBESTY.html +++ b/docs/api/ioh.iohcpp.logger.property.CURRENTBESTY.html @@ -3,10 +3,10 @@ - + - CURRENTBESTY - IOHExperimenter 0.3.10 documentation + CurrentBestY - IOHExperimenter 0.3.10 documentation @@ -328,7 +328,7 @@
  • OnViolation
  • Trigger
  • AbstractProperty
  • -
  • CurrentBestY
  • +
  • CurrentBestY
  • CurrentY
  • Evaluations
  • Penalty
  • @@ -338,7 +338,7 @@
  • TransformedY
  • TransformedYBest
  • Violation
  • -
  • CURRENTBESTY
  • +
  • CURRENTBESTY
  • CURRENTY
  • EVALUATIONS
  • PENALTY
  • @@ -405,12 +405,46 @@
    -

    CURRENTBESTY#

    -
    -
    -ioh.iohcpp.logger.property.CURRENTBESTY = <ioh.iohcpp.logger.property.CurrentBestY object>#
    +

    CurrentBestY#

    +
    +
    +class ioh.iohcpp.logger.property.CurrentBestY(self: ioh.iohcpp.logger.property.CurrentBestY, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the CurrentBestY

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    CURRENTBESTY - +
    Next
    -
    CURRENTY
    +
    CurrentY
    - +
    Previous
    -
    Violation
    +
    AbstractProperty
    diff --git a/docs/api/ioh.iohcpp.logger.property.CURRENTY.html b/docs/api/ioh.iohcpp.logger.property.CURRENTY.html index bde3c9b7c..a29c11a96 100644 --- a/docs/api/ioh.iohcpp.logger.property.CURRENTY.html +++ b/docs/api/ioh.iohcpp.logger.property.CURRENTY.html @@ -3,10 +3,10 @@ - + - CURRENTY - IOHExperimenter 0.3.10 documentation + CurrentY - IOHExperimenter 0.3.10 documentation @@ -329,7 +329,7 @@
  • Trigger
  • AbstractProperty
  • CurrentBestY
  • -
  • CurrentY
  • +
  • CurrentY
  • Evaluations
  • Penalty
  • Property
  • @@ -339,7 +339,7 @@
  • TransformedYBest
  • Violation
  • CURRENTBESTY
  • -
  • CURRENTY
  • +
  • CURRENTY
  • EVALUATIONS
  • PENALTY
  • RAWY
  • @@ -405,12 +405,46 @@
    -

    CURRENTY#

    -
    -
    -ioh.iohcpp.logger.property.CURRENTY = <ioh.iohcpp.logger.property.CurrentY object>#
    +

    CurrentY#

    +
    +
    +class ioh.iohcpp.logger.property.CurrentY(self: ioh.iohcpp.logger.property.CurrentY, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the CurrentY

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    CURRENTY - +
    Next
    -
    EVALUATIONS
    +
    Evaluations
    - +
    Previous
    -
    CURRENTBESTY
    +
    CurrentBestY
    diff --git a/docs/api/ioh.iohcpp.logger.property.EVALUATIONS.html b/docs/api/ioh.iohcpp.logger.property.EVALUATIONS.html index 02eb2351f..c027647e2 100644 --- a/docs/api/ioh.iohcpp.logger.property.EVALUATIONS.html +++ b/docs/api/ioh.iohcpp.logger.property.EVALUATIONS.html @@ -3,10 +3,10 @@ - + - EVALUATIONS - IOHExperimenter 0.3.10 documentation + Evaluations - IOHExperimenter 0.3.10 documentation @@ -330,7 +330,7 @@
  • AbstractProperty
  • CurrentBestY
  • CurrentY
  • -
  • Evaluations
  • +
  • Evaluations
  • Penalty
  • Property
  • RawY
  • @@ -340,7 +340,7 @@
  • Violation
  • CURRENTBESTY
  • CURRENTY
  • -
  • EVALUATIONS
  • +
  • EVALUATIONS
  • PENALTY
  • RAWY
  • RAWYBEST
  • @@ -405,12 +405,46 @@
    -

    EVALUATIONS#

    -
    -
    -ioh.iohcpp.logger.property.EVALUATIONS = <ioh.iohcpp.logger.property.Evaluations object>#
    +

    Evaluations#

    +
    +
    +class ioh.iohcpp.logger.property.Evaluations(self: ioh.iohcpp.logger.property.Evaluations, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the Evaluations

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    EVALUATIONS - +
    Next
    -
    PENALTY
    +
    Penalty
    - +
    Previous
    -
    CURRENTY
    +
    CurrentY
    diff --git a/docs/api/ioh.iohcpp.logger.property.PENALTY.html b/docs/api/ioh.iohcpp.logger.property.PENALTY.html index 308af719a..5efd37acb 100644 --- a/docs/api/ioh.iohcpp.logger.property.PENALTY.html +++ b/docs/api/ioh.iohcpp.logger.property.PENALTY.html @@ -3,10 +3,10 @@ - + - PENALTY - IOHExperimenter 0.3.10 documentation + Penalty - IOHExperimenter 0.3.10 documentation @@ -331,7 +331,7 @@
  • CurrentBestY
  • CurrentY
  • Evaluations
  • -
  • Penalty
  • +
  • Penalty
  • Property
  • RawY
  • RawYBest
  • @@ -341,7 +341,7 @@
  • CURRENTBESTY
  • CURRENTY
  • EVALUATIONS
  • -
  • PENALTY
  • +
  • PENALTY
  • RAWY
  • RAWYBEST
  • TRANSFORMEDY
  • @@ -405,12 +405,46 @@
    -

    PENALTY#

    -
    -
    -ioh.iohcpp.logger.property.PENALTY = <ioh.iohcpp.logger.property.Penalty object>#
    +

    Penalty#

    +
    +
    +class ioh.iohcpp.logger.property.Penalty(self: ioh.iohcpp.logger.property.Penalty, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the Penalty

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    PENALTY - +
    Next
    -
    RAWY
    +
    Property
    - +
    Previous
    -
    EVALUATIONS
    +
    Evaluations
    diff --git a/docs/api/ioh.iohcpp.logger.property.RAWY.html b/docs/api/ioh.iohcpp.logger.property.RAWY.html index 6c310c4fa..b6f099ceb 100644 --- a/docs/api/ioh.iohcpp.logger.property.RAWY.html +++ b/docs/api/ioh.iohcpp.logger.property.RAWY.html @@ -3,10 +3,10 @@ - + - RAWY - IOHExperimenter 0.3.10 documentation + RawY - IOHExperimenter 0.3.10 documentation @@ -333,7 +333,7 @@
  • Evaluations
  • Penalty
  • Property
  • -
  • RawY
  • +
  • RawY
  • RawYBest
  • TransformedY
  • TransformedYBest
  • @@ -342,7 +342,7 @@
  • CURRENTY
  • EVALUATIONS
  • PENALTY
  • -
  • RAWY
  • +
  • RAWY
  • RAWYBEST
  • TRANSFORMEDY
  • TRANSFORMEDYBEST
  • @@ -405,12 +405,46 @@
    -

    RAWY#

    -
    -
    -ioh.iohcpp.logger.property.RAWY = <ioh.iohcpp.logger.property.RawY object>#
    +

    RawY#

    +
    +
    +class ioh.iohcpp.logger.property.RawY(self: ioh.iohcpp.logger.property.RawY, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the RawY

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    RAWY#
    -

    RAWYBEST#

    -
    -
    -ioh.iohcpp.logger.property.RAWYBEST = <ioh.iohcpp.logger.property.RawYBest object>#
    +

    RawYBest#

    +
    +
    +class ioh.iohcpp.logger.property.RawYBest(self: ioh.iohcpp.logger.property.RawYBest, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the RawYBest

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    RAWYBEST - +
    Next
    -
    TRANSFORMEDY
    +
    TransformedY
    - +
    Previous
    -
    RAWY
    +
    RawY
    diff --git a/docs/api/ioh.iohcpp.logger.property.TRANSFORMEDY.html b/docs/api/ioh.iohcpp.logger.property.TRANSFORMEDY.html index 41d095bc7..ece8a2610 100644 --- a/docs/api/ioh.iohcpp.logger.property.TRANSFORMEDY.html +++ b/docs/api/ioh.iohcpp.logger.property.TRANSFORMEDY.html @@ -3,10 +3,10 @@ - + - TRANSFORMEDY - IOHExperimenter 0.3.10 documentation + TransformedY - IOHExperimenter 0.3.10 documentation @@ -335,7 +335,7 @@
  • Property
  • RawY
  • RawYBest
  • -
  • TransformedY
  • +
  • TransformedY
  • TransformedYBest
  • Violation
  • CURRENTBESTY
  • @@ -344,7 +344,7 @@
  • PENALTY
  • RAWY
  • RAWYBEST
  • -
  • TRANSFORMEDY
  • +
  • TRANSFORMEDY
  • TRANSFORMEDYBEST
  • VIOLATION
  • AbstractLogger
  • @@ -405,12 +405,46 @@
    -

    TRANSFORMEDY#

    -
    -
    -ioh.iohcpp.logger.property.TRANSFORMEDY = <ioh.iohcpp.logger.property.TransformedY object>#
    +

    TransformedY#

    +
    +
    +class ioh.iohcpp.logger.property.TransformedY(self: ioh.iohcpp.logger.property.TransformedY, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the TransformedY

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    TRANSFORMEDY - +
    Next
    -
    TRANSFORMEDYBEST
    +
    TransformedYBest
    - +
    Previous
    -
    RAWYBEST
    +
    RawYBest
    diff --git a/docs/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.html b/docs/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.html index 8ffb86f8d..91d22f1e0 100644 --- a/docs/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.html +++ b/docs/api/ioh.iohcpp.logger.property.TRANSFORMEDYBEST.html @@ -3,10 +3,10 @@ - + - TRANSFORMEDYBEST - IOHExperimenter 0.3.10 documentation + TransformedYBest - IOHExperimenter 0.3.10 documentation @@ -336,7 +336,7 @@
  • RawY
  • RawYBest
  • TransformedY
  • -
  • TransformedYBest
  • +
  • TransformedYBest
  • Violation
  • CURRENTBESTY
  • CURRENTY
  • @@ -345,7 +345,7 @@
  • RAWY
  • RAWYBEST
  • TRANSFORMEDY
  • -
  • TRANSFORMEDYBEST
  • +
  • TRANSFORMEDYBEST
  • VIOLATION
  • AbstractLogger
  • Analyzer
  • @@ -405,12 +405,46 @@
    -

    TRANSFORMEDYBEST#

    -
    -
    -ioh.iohcpp.logger.property.TRANSFORMEDYBEST = <ioh.iohcpp.logger.property.TransformedYBest object>#
    +

    TransformedYBest#

    +
    +
    +class ioh.iohcpp.logger.property.TransformedYBest(self: ioh.iohcpp.logger.property.TransformedYBest, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the TransformedYBest

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    TRANSFORMEDYBEST - +
    Next
    -
    VIOLATION
    +
    Violation
    - +
    Previous
    -
    TRANSFORMEDY
    +
    TransformedY
    diff --git a/docs/api/ioh.iohcpp.logger.property.VIOLATION.html b/docs/api/ioh.iohcpp.logger.property.VIOLATION.html index 06b91bdb1..bf8acf59e 100644 --- a/docs/api/ioh.iohcpp.logger.property.VIOLATION.html +++ b/docs/api/ioh.iohcpp.logger.property.VIOLATION.html @@ -3,10 +3,10 @@ - + - VIOLATION - IOHExperimenter 0.3.10 documentation + Violation - IOHExperimenter 0.3.10 documentation @@ -337,7 +337,7 @@
  • RawYBest
  • TransformedY
  • TransformedYBest
  • -
  • Violation
  • +
  • Violation
  • CURRENTBESTY
  • CURRENTY
  • EVALUATIONS
  • @@ -346,7 +346,7 @@
  • RAWYBEST
  • TRANSFORMEDY
  • TRANSFORMEDYBEST
  • -
  • VIOLATION
  • +
  • VIOLATION
  • AbstractLogger
  • Analyzer
  • Combine
  • @@ -405,12 +405,46 @@
    -

    VIOLATION#

    -
    -
    -ioh.iohcpp.logger.property.VIOLATION = <ioh.iohcpp.logger.property.Violation object>#
    +

    Violation#

    +
    +
    +class ioh.iohcpp.logger.property.Violation(self: ioh.iohcpp.logger.property.Violation, name: str, format: str)#
    +

    Bases: AbstractProperty

    +

    Property which tracks the Violation

    +

    Methods Summary

    +
    + + + + + + + + + + + + +

    __call__(self, arg0)

    call_to_string(self, arg0, arg1)

    name(self)

    +
    +

    Methods Documentation

    +
    +
    +__call__(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo) Optional[float]#
    +
    + +
    +
    +call_to_string(self: ioh.iohcpp.logger.property.AbstractProperty, arg0: ioh.iohcpp.LogInfo, arg1: str) str#
    +
    +
    +name(self: ioh.iohcpp.logger.property.AbstractProperty) str#
    +
    + +
    +
    @@ -418,23 +452,23 @@

    VIOLATION - +
    Next
    -
    AbstractLogger
    +
    CURRENTBESTY
    - +
    Previous
    -
    TRANSFORMEDYBEST
    +
    TransformedYBest
    diff --git a/docs/api/ioh.iohcpp.problem.GriewankRosenBrock.html b/docs/api/ioh.iohcpp.problem.GriewankRosenBrock.html index ada959abf..1cf5ef19a 100644 --- a/docs/api/ioh.iohcpp.problem.GriewankRosenBrock.html +++ b/docs/api/ioh.iohcpp.problem.GriewankRosenBrock.html @@ -6,7 +6,7 @@ - GriewankRosenBrock - IOHExperimenter 0.3.8 documentation + GriewankRosenbrock - IOHExperimenter 0.3.10 documentation @@ -124,7 +124,7 @@
    @@ -147,7 +147,7 @@
    -

    GriewankRosenBrock#

    +

    GriewankRosenbrock#

    -
    -class ioh.iohcpp.problem.GriewankRosenBrock(self: ioh.iohcpp.problem.GriewankRosenBrock, instance: int, n_variables: int)#
    +
    +class ioh.iohcpp.problem.GriewankRosenbrock(self: ioh.iohcpp.problem.GriewankRosenbrock, instance: int, n_variables: int)#

    Bases: BBOB

    Attributes Summary

    - + - + - - + + - + - + - + - + @@ -487,28 +442,28 @@

    GriewankRosenBrock

    bounds

    bounds

    The bounds of the problem.

    constraints

    constraints

    The constraints of the problem.

    log_info

    log_info

    The data is that being sent to the logger.

    meta_data

    meta_data

    The static meta-data of the problem containing, e.g., problem id, instance id, and problem's dimensionality

    optimum

    optimum

    The optimum and its objective value for a problem instance

    problems

    problems

    state

    state

    The current state of the optimization process containing, e.g., the current solution and the number of function evaluated consumed so far

    - + - + - + - + - + - - + + - + - + @@ -516,66 +471,85 @@

    GriewankRosenBrockAttributes Documentation

    -
    -bounds#
    +
    +bounds#

    The bounds of the problem.

    -
    -constraints#
    +
    +constraints#

    The constraints of the problem.

    -
    -log_info#
    -
    +
    +log_info#
    +

    The data is that being sent to the logger.

    +
    -
    -meta_data#
    +
    +meta_data#

    The static meta-data of the problem containing, e.g., problem id, instance id, and problem’s dimensionality

    -
    -optimum#
    +
    +optimum#

    The optimum and its objective value for a problem instance

    -
    -problems#
    +
    +problems#
    -
    -state#
    +
    +state#

    The current state of the optimization process containing, e.g., the current solution and the number of function evaluated consumed so far

    Methods Documentation

    -
    -__call__()#
    +
    +__call__()#

    Evaluate the problem.

    Parameters:

    x (list) – the search point to evaluate. It must be a 1-dimensional array/list whose length matches search space’s dimensionality

    +
    Returns:
    +

    The evaluated search point

    +
    +
    Return type:
    +

    float

    +
    +
    +

    Evaluate the problem.

    +
    +
    Parameters:
    +

    x (list[list]) – the search points to evaluate. It must be a 2-dimensional array/list whose length matches search space’s dimensionality

    +
    +
    Returns:
    +

    The evaluated search points

    +
    +
    Return type:
    +

    list[float]

    +
    -
    -add_constraint()#
    +
    +add_constraint()#

    add a constraint

    -
    -attach_logger()#
    +
    +attach_logger()#

    Attach a logger to the problem to allow performance tracking.

    Parameters:
    @@ -585,8 +559,8 @@

    GriewankRosenBrock -
    -static create(*args, **kwargs)#
    +
    +static create(*args, **kwargs)#

    Overloaded function.

    1. create(problem_name: str, instance_id: int, dimension: int) -> ioh.iohcpp.problem.BBOB

      @@ -623,25 +597,32 @@

      GriewankRosenBrock -
      -detach_logger()#
      +
      +detach_logger()#

      Remove the specified logger from the problem.

    -
    -enforce_bounds()#
    -
    +
    +enforce_bounds()#
    +

    Enforced the bounds (box-constraints) as constraint +:param weight: +:type weight: The weight for computing the penalty (can be infinity to have strict box-constraints) +:param how: +:type how: The enforcement strategy, should be one of the ‘ioh.ConstraintEnforcement’ options +:param exponent: +:type exponent: The exponent for scaling the contraint

    +
    -
    -remove_constraint()#
    +
    +remove_constraint()#

    remove a constraint

    -
    -reset()#
    +
    +reset()#

    Reset all state variables of the problem.

    diff --git a/include/ioh/common/file.hpp b/include/ioh/common/file.hpp index ae409ad4c..3fb9f09f7 100644 --- a/include/ioh/common/file.hpp +++ b/include/ioh/common/file.hpp @@ -7,6 +7,7 @@ #include #include +#include #ifdef FSEXPERIMENTAL #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 @@ -396,18 +397,6 @@ namespace ioh::common::file }; - inline char *get_error() - { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4996) - return strerror(errno); -#pragma warning(pop) -#else - return strerror(errno); -#endif - } - inline FILE *open_file(const fs::path &path) { #ifdef _MSC_VER @@ -420,27 +409,54 @@ namespace ioh::common::file #endif } - struct Writer { - void open(const fs::path &new_path) = 0; - void close() = 0; - bool is_open() = 0; - void write(const std::string&) = 0; + struct Writer + { + virtual void open(const fs::path &new_path) = 0; + virtual void close() = 0; + virtual bool is_open() = 0; + virtual void write(const std::string &) = 0; }; + struct OFStream : Writer + { + std::ofstream out_; + fs::path path_; + OFStream() : out_{} {} - constexpr const size_t KB = 1024; - constexpr const size_t CACHE_SIZE = 4 * KB; + virtual ~OFStream() { close(); } + + void open(const fs::path &new_path) override + { + close(); + path_ = new_path; + out_.open(new_path); + }; + void close() override + { + if (is_open()) + { + out_.close(); + } + }; + bool is_open() override { return out_.is_open(); }; + void write(const std::string &s) override { out_ << s; }; + }; - struct CachedFile + struct FWriter : Writer { fs::path path; FILE *file_ptr; - std::array buffer; - size_t buffered_elements; - CachedFile() : path{}, file_ptr{nullptr}, buffer{}, buffered_elements{0} {} - void open(const fs::path &new_path) + size_t buffer_size; + int buffer_mode; + + FWriter(size_t buffer_size = 0, int buffer_mode = _IOFBF) : + path{}, file_ptr{nullptr}, buffer_size{buffer_size}, buffer_mode{buffer_mode} + { + } + + void open(const fs::path &new_path) override { close(); path = new_path; @@ -448,41 +464,99 @@ namespace ioh::common::file if (file_ptr == NULL) { - std::cerr << "creating cachedfile: " << get_error() << std::endl; + std::perror("creating cachedfile"); + return; } + if (buffer_size != 0) + { + std::cout << "BUFSIZ is " << BUFSIZ << ", setting to " << buffer_size << '\n'; + if (std::setvbuf(file_ptr, nullptr, buffer_mode, buffer_size) != 0) + std::perror("setvbuf failed"); + } +#ifndef _MSC_VER + else + { + struct stat stats; + if (fstat(fileno(file_ptr), &stats) != -1) // POSIX only + { + std::cout << "BUFSIZ is " << BUFSIZ << ", but optimal block size is " << stats.st_blksize << '\n'; + if (std::setvbuf(file_ptr, nullptr, _IOFBF, stats.st_blksize) != 0) + { + std::perror("setvbuf failed"); // POSIX version sets errno + } + } + } +#endif } - void close() + void close() override { if (is_open()) { - write_chunk(); close_file(); - buffered_elements = 0; path.clear(); } } - void close_file() { + void close_file() + { fclose(file_ptr); file_ptr = nullptr; } - bool is_open() const { return file_ptr != nullptr; } + bool is_open() override { return file_ptr != nullptr; } + + virtual ~FWriter() { close(); } + + + virtual void write(const char *data, const size_t data_size) + { + const auto ret = fwrite(data, sizeof(char), data_size, file_ptr); + if (ret != data_size) + std::perror("writing fwrite"); + } + + void write(const std::string &s) override { write(s.data(), s.size()); } + }; - virtual ~CachedFile() { close(); } + + constexpr const size_t KB = 1024; + constexpr const size_t CACHE_SIZE = 16 * KB; + + struct CachedFWriter : FWriter + { + std::array buffer; + size_t buffered_elements; + + CachedFWriter() : FWriter{}, buffer{}, buffered_elements{0} {} + + void close() override + { + if (is_open()) + { + write_chunk(); + close_file(); + buffered_elements = 0; + path.clear(); + } + } + void open(const fs::path &new_path) override + { + FWriter::open(new_path); + std::setvbuf(file_ptr, nullptr, _IONBF, 0); + } + + virtual ~CachedFWriter() { close(); } void write_chunk() { const auto ret = fwrite(buffer.data(), sizeof(char), buffered_elements, file_ptr); if (ret != buffered_elements) - { - std::cerr << "writing cached file: " << get_error() << std::endl; - } + std::perror("writing cached file"); buffered_elements = 0; } - void write(const char *data, const size_t data_size) + void write(const char *data, const size_t data_size) override { size_t bytes_written = 0; while (bytes_written < data_size) @@ -498,7 +572,5 @@ namespace ioh::common::file write_chunk(); } } - - void write(const std::string &s) { write(s.data(), s.size()); } }; } // namespace ioh::common::file diff --git a/include/ioh/logger/flatfile.hpp b/include/ioh/logger/flatfile.hpp index 2d514b132..abe808672 100644 --- a/include/ioh/logger/flatfile.hpp +++ b/include/ioh/logger/flatfile.hpp @@ -58,7 +58,7 @@ namespace ioh::logger std::string filename_; //! Output stream - std::unique_ptr out_; + std::shared_ptr out_; //! Current run size_t current_run_; @@ -124,13 +124,14 @@ namespace ioh::logger common_header_(format("{}", fmt::join(common_header_titles.begin(), common_header_titles.end(), sep_)) + (common_header_titles.empty() ? "" : sep_)), repeat_header_(repeat_header), store_positions_(store_positions), requires_header_(true), - log_meta_data_(!common_header_titles.empty()), output_directory_(output_directory), filename_(filename), out_{}, + log_meta_data_(!common_header_titles.empty()), output_directory_(output_directory), + filename_(filename), out_{std::make_shared()}, current_run_(0), current_meta_data_{} { assert(common_header_titles.empty() || common_header_titles.size() == 7); } - + void set_writer(const std::shared_ptr& w) { out_ = w; } void attach_problem(const problem::MetaData &problem) override { @@ -173,7 +174,10 @@ namespace ioh::logger IOH_DBG(xdebug, "print watched properties") for (auto p = properties_vector_.begin(); p != properties_vector_.end();){ - out_->write(p->get().call_to_string(log_info, nan_) << (++p != properties_vector_.end() ? sep_ : "")); + auto str = p->get().call_to_string(log_info, nan_); + if (++p != properties_vector_.end()) + str += sep_; + out_->write(str); } if (store_positions_) diff --git a/ioh/src/logger.cpp b/ioh/src/logger.cpp index 3fe37bc3d..8269e0391 100644 --- a/ioh/src/logger.cpp +++ b/ioh/src/logger.cpp @@ -163,6 +163,27 @@ class PyAnalyzer : public PyWatcher } }; +void define_writers(py::module &m) { + using namespace ioh::common::file; + + py::class_>(m, "Writer") + .def("open", py::arg("path"), &Writer::open) + .def("close", &Writer::close) + .def("is_open", &Writer::is_open) + .def("write", &Writer::write, py::arg("data")) + ; + + py::class_>(m, "OFStream").def(py::init<>()); + py::class_>(m, "FWriter").def( + py::init(), + py::arg("buffer_size") = 0, + py:arg("buffer_mode") = _IOFBF + ); + py::class_>(m, "CachedFWriter").def(py::init<>()); + +} + + template void define_analyzer(py::module &m) { diff --git a/tests/cpp/logger/test_flatfile.cpp b/tests/cpp/logger/test_flatfile.cpp index 21a629ad5..275e03b2d 100644 --- a/tests/cpp/logger/test_flatfile.cpp +++ b/tests/cpp/logger/test_flatfile.cpp @@ -6,7 +6,7 @@ using namespace ioh; -TEST_F(BaseTest, logger_flatfile) +size_t test_for_writer(const std::shared_ptr& writer) { auto p0 = problem::bbob::Sphere(1, 2); auto p1 = problem::bbob::Sphere(1, 4); @@ -15,15 +15,20 @@ TEST_F(BaseTest, logger_flatfile) trigger::Always always; watch::TransformedY transformed_y; { - auto logger = logger::FlatFile( {always}, {transformed_y}, "IOH.dat", "." ); + auto logger = logger::FlatFile({always}, {transformed_y}, "IOH.dat", "."); + logger.set_writer(writer); + common::random::seed(1); const int runs = 3; const int samples = 3; - - for(auto pb : std::array({&p0,&p1,&p2})) { + + for (auto pb : std::array({&p0, &p1, &p2})) + { pb->attach_logger(logger); - for(auto r = 0; r < runs; ++r) { - for(auto s = 0; s < samples; ++s) { + for (auto r = 0; r < runs; ++r) + { + for (auto s = 0; s < samples; ++s) + { (*pb)(common::random::pbo::uniform(pb->meta_data().n_variables, s)); } pb->reset(); @@ -32,8 +37,18 @@ TEST_F(BaseTest, logger_flatfile) } EXPECT_TRUE(fs::exists("./IOH.dat")); auto data = ioh::common::file::as_string("./IOH.dat"); - std::cout << data << std::endl; - EXPECT_GT(data.size(),0); + //std::cout << data << std::endl; + EXPECT_GT(data.size(), 0); fs::remove("./IOH.dat"); EXPECT_TRUE(!fs::exists("./IOH.dat")); + return data.size(); +} + +TEST_F(BaseTest, logger_flatfile) { + auto n1 = test_for_writer(std::make_shared()); + auto n2 = test_for_writer(std::make_shared()); + auto n3 = test_for_writer(std::make_shared()); + auto n4 = test_for_writer(std::make_shared(4096)); + + EXPECT_TRUE(n1 == n2 && n2 == n3 && n3 == n4) << n1 << " " << n2 << " " << n3 << " " << n4; }

    __call__

    __call__

    Evaluate the problem.

    add_constraint

    add_constraint

    add a constraint

    attach_logger

    attach_logger

    Attach a logger to the problem to allow performance tracking.

    create(*args, **kwargs)

    create(*args, **kwargs)

    Overloaded function.

    detach_logger

    detach_logger

    Remove the specified logger from the problem.

    enforce_bounds

    enforce_bounds

    Enforced the bounds (box-constraints) as constraint :param weight: :type weight: The weight for computing the penalty (can be infinity to have strict box-constraints) :param how: :type how: The enforcement strategy, should be one of the 'ioh.ConstraintEnforcement' options :param exponent: :type exponent: The exponent for scaling the contraint

    remove_constraint

    remove_constraint

    remove a constraint

    reset

    reset

    Reset all state variables of the problem.