Parameters: mark out the base operations of a Scale
Scales are defined as descriptor records and will be used as const. Besides some information functions, a Scale * allows to conform a value to be compliant with the Scale's constraints * can ''join'' and thus apply a ''feed'' on top of a ''base value''; this is the foundation for applying an automation function, while handling multiplicative and logarithmic cases properly
This commit is contained in:
parent
50ef9dd985
commit
4e4222ebc7
4 changed files with 157 additions and 31 deletions
|
|
@ -27,9 +27,9 @@
|
|||
** mostly at start and then hold and use the memory, the allocation is never
|
||||
** actually _closed_ — implying that further allocations can be added during
|
||||
** the whole life time, which may possibly even trigger a further base allocation
|
||||
** if storage space in the last Extent is exhausted. In theory, it would be possible
|
||||
** if storage space if the last Extent is exhausted. In theory, it would be possible
|
||||
** to use a custom allocation (in the AllocationCluster::StorageManager::Extents,
|
||||
** which is a lib::LinkedElements and could be parametrised with a allocator template).
|
||||
** which is a lib::LinkedElements and could be parametrised with an allocator template).
|
||||
** Allocations are never discarded, and thus any alloted memory will be kept until
|
||||
** the whole AllocationCluster is destroyed as a compound.
|
||||
** \par using as STL allocator
|
||||
|
|
|
|||
|
|
@ -63,12 +63,98 @@ namespace par {
|
|||
optional<VAL> minUse{};
|
||||
optional<VAL> maxUse{};
|
||||
optional<VAL> neutral{};
|
||||
optional<VAL> defaultVal{};
|
||||
optional<VAL> defVal{};
|
||||
/////////////////////////////OOO »Sentinels« and nominal scales?
|
||||
bool zyclic{false};
|
||||
|
||||
/* ===== information functions ===== */
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
/* ===== conforming operations ===== */
|
||||
|
||||
VAL conform (VAL const&) const;
|
||||
|
||||
template<typename SRC>
|
||||
VAL join (VAL const&, SRC const&, Scale<SRC> const&) const;
|
||||
VAL join (VAL const&, VAL const&) const;
|
||||
};
|
||||
|
||||
|
||||
/* ===== information functions ===== */
|
||||
|
||||
/** self consistency check */
|
||||
template<typename VAL>
|
||||
inline bool
|
||||
Scale<VAL>::isValid() const
|
||||
{
|
||||
return ((not minVal or not maxVal)
|
||||
or *minVal <= *maxVal
|
||||
)
|
||||
and (not minUse
|
||||
or (not minVal or *minVal <= *minUse)
|
||||
)
|
||||
and (not maxUse
|
||||
or (not maxVal or *maxUse <= *maxVal)
|
||||
)
|
||||
and ((not minUse or not maxUse)
|
||||
or *minUse <= *maxUse
|
||||
)
|
||||
and (not neutral
|
||||
or ( (not maxVal or *neutral <= *maxVal)
|
||||
and (not minVal or *minVal <= *neutral)
|
||||
)
|
||||
)
|
||||
and (not defVal
|
||||
or ( (not maxVal or *defVal <= *maxVal)
|
||||
and (not minVal or *minVal <= *defVal)
|
||||
)
|
||||
)
|
||||
and (not zyclic
|
||||
or (minVal and maxVal)
|
||||
or (minVal and neutral)
|
||||
or (neutral and maxVal)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/* ===== conforming operations ===== */
|
||||
|
||||
/**
|
||||
* Accommodate a raw value from the underlying domain,
|
||||
* so that it conforms with this Scale definition.
|
||||
*/
|
||||
template<typename VAL>
|
||||
inline VAL
|
||||
Scale<VAL>::conform (VAL const& rawVal) const
|
||||
{
|
||||
UNIMPLEMENTED ("Scale conforming");
|
||||
}
|
||||
|
||||
/**
|
||||
* Join and combine an additional feed value with an anchor value.
|
||||
* @note actual joining operation is picked based on both scales and types involved.
|
||||
* @remark notably multiplicative contributions and logarithmic scales to be considered.
|
||||
*/
|
||||
template<typename VAL>
|
||||
template<typename SRC>
|
||||
inline VAL
|
||||
Scale<VAL>::join (VAL const& value, SRC const& feed, Scale<SRC> const& feedScale) const
|
||||
{
|
||||
UNIMPLEMENTED ("join a feed with a base value, observing Scale constraints");
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplified join() variant, assuming the feed is based on the same scale.
|
||||
*/
|
||||
template<typename VAL>
|
||||
inline VAL
|
||||
Scale<VAL>::join (VAL const& vaule, VAL const& feed) const
|
||||
{
|
||||
UNIMPLEMENTED ("join a feed with a base value within same Scale");
|
||||
}
|
||||
|
||||
|
||||
}} // namespace lib::par
|
||||
#endif /*LIB_PAR_SCALE_H*/
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "test/run.hpp"
|
||||
//#include "test/test-helper.hpp"
|
||||
#include "lib/par/parameter.hpp"
|
||||
#include "lib/par/scale.hpp"
|
||||
#include "test/diagnostic-output.hpp"/////////////TODO
|
||||
|
||||
//#include <utility>
|
||||
|
|
@ -58,14 +58,21 @@ namespace test{
|
|||
run (Arg)
|
||||
{
|
||||
simpleUsage();
|
||||
verify_typeMarker();
|
||||
verify_Bounds();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
simpleUsage()
|
||||
{
|
||||
UNIMPLEMENTED ("nebbich");
|
||||
Scale<int> scale = {.minVal = -5, .maxVal = 23};
|
||||
CHECK (scale.isValid());
|
||||
|
||||
CHECK (-5 == scale.conform (-55));
|
||||
CHECK (23 == scale.conform (+55));
|
||||
|
||||
CHECK ( 5 == scale.join (2,3) );
|
||||
CHECK (-5 == scale.join (23,-55));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -73,7 +80,7 @@ namespace test{
|
|||
* @todo WIP 9/26 🔁 define ⟶ implement
|
||||
*/
|
||||
void
|
||||
verify_typeMarker()
|
||||
verify_Bounds()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -85424,7 +85424,8 @@
|
|||
</node>
|
||||
<node CREATED="1788904412352" ID="ID_1436845505" MODIFIED="1788904424447" TEXT="ein ähnliches Verdikt gilt für zyklische Werte"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#ccb59b" COLOR="#6e2a38" CREATED="1788912980176" ID="ID_320664672" MODIFIED="1788913437098" TEXT="Beschluß: geläufige Sonderfälle explizit mit aufnehmen">
|
||||
<node BACKGROUND_COLOR="#ccb59b" COLOR="#6e2a38" CREATED="1788912980176" ID="ID_320664672" MODIFIED="1789160197623" TEXT="Beschluß: geläufige Sonderfälle explizit mit aufnehmen">
|
||||
<linktarget COLOR="#852a28" DESTINATION="ID_320664672" ENDARROW="Default" ENDINCLINATION="-765;515;" ID="Arrow_ID_1819779589" SOURCE="ID_1480074646" STARTARROW="None" STARTINCLINATION="199;8;"/>
|
||||
<font ITALIC="true" NAME="SansSerif" SIZE="14"/>
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1788913085119" ID="ID_321653591" MODIFIED="1788913092162" TEXT="Zahlenwert-artige Skalen"/>
|
||||
|
|
@ -85551,9 +85552,10 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1788917794598" ID="ID_29123926" MODIFIED="1788917818108" TEXT="ValueChain">
|
||||
<node CREATED="1788917794598" ID="ID_29123926" MODIFIED="1789161706991" TEXT="Value-Chaining">
|
||||
<node CREATED="1789161718416" ID="ID_343593959" MODIFIED="1789165376887" TEXT="join (value, feed[, feedScale const&])"/>
|
||||
<node CREATED="1788917819659" ID="ID_1748818920" MODIFIED="1788917847680" TEXT="wird benötigt um die Automations-Provision auf einen Basis-Wert anzuwenden"/>
|
||||
<node CREATED="1788917877107" ID="ID_665324760" MODIFIED="1788918801557" TEXT="hängt ab...">
|
||||
<node CREATED="1788917877107" ID="ID_665324760" MODIFIED="1788917877107" TEXT="hängt ab...">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
|
|
@ -85564,8 +85566,15 @@
|
|||
</html></richcontent>
|
||||
<node CREATED="1788917882892" ID="ID_52090158" MODIFIED="1788917894364" TEXT="von der Metrik des Ergebnis-Parameters"/>
|
||||
<node CREATED="1788917904223" ID="ID_1099728874" MODIFIED="1788917932855" TEXT="ggfs von einer abweichenden Scale der Automations-Provision"/>
|
||||
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1789164533222" ID="ID_1017590695" MODIFIED="1789164556832" TEXT="Problem: kann auch vom Typ des Beitrags (und des Basis-Werts) abhängen">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
<node CREATED="1789164561486" ID="ID_376197998" MODIFIED="1789164593909" TEXT="bedeutet: die darauf aufbauende Provision muß ggfs. einen double-Dispatch machen"/>
|
||||
<node CREATED="1789165221192" ID="ID_388299163" MODIFIED="1789165234448" TEXT="die Basis-Implementierung muß dann generisch sein und von Scale bereitgestellt werden"/>
|
||||
<node CREATED="1789165187065" ID="ID_1109273270" MODIFIED="1789165213989" TEXT="Konsequenz ⟹ die Scale muß hier zwei Typ-Parameter nehmen"/>
|
||||
<node CREATED="1789165444623" ID="ID_1649021234" MODIFIED="1789165459491" TEXT="vereinfachte Variante für identische Scale"/>
|
||||
</node>
|
||||
<node CREATED="1788918491304" ID="ID_991615591" MODIFIED="1788918753513" TEXT="Beschluß: hier Heuristik — keine eigene Taxonomie">
|
||||
</node>
|
||||
<node CREATED="1788918491304" ID="ID_991615591" MODIFIED="1788918491304" TEXT="Beschluß: hier Heuristik — keine eigene Taxonomie">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
|
|
@ -85593,7 +85602,8 @@
|
|||
<node CREATED="1789072817738" ID="ID_621244531" MODIFIED="1789072844560" TEXT="man könnte »Scales« ins Zentrum stellen — oder als Rand-Thema betrachten"/>
|
||||
<node CREATED="1789073532638" ID="ID_1112609990" MODIFIED="1789073555185" TEXT="Eine Frage des »Navigierens« : was verbaut man sich und womit verspielt man sich"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#accdc3" COLOR="#3f4015" CREATED="1789002615502" ID="ID_1161327543" LINK="https://claude.ai/share/784807f3-8fb3-4c1f-85c0-95355e79a9db" MODIFIED="1789082794573" TEXT="eine Design-Konversation mit Claude geführt">
|
||||
<node BACKGROUND_COLOR="#accdc3" COLOR="#3f4015" CREATED="1789002615502" ID="ID_1161327543" LINK="https://claude.ai/share/784807f3-8fb3-4c1f-85c0-95355e79a9db" MODIFIED="1789082726792" TEXT="eine Design-Konversation mit Claude geführt">
|
||||
<linktarget COLOR="#51bbdf" DESTINATION="ID_1161327543" ENDARROW="Default" ENDINCLINATION="231;13;" ID="Arrow_ID_994670578" SOURCE="ID_383248634" STARTARROW="None" STARTINCLINATION="-183;-140;"/>
|
||||
<icon BUILTIN="wizard"/>
|
||||
<node CREATED="1789002670195" ID="ID_1638903618" MODIFIED="1789074297728" TEXT="Schritt-1 : gebe ihm nur high-level Kontext">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
|
|
@ -85867,7 +85877,8 @@
|
|||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1789082704022" ID="ID_1925473607" MODIFIED="1789082723794" TEXT="muß eine Registry bereits jetzt bauen">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node BACKGROUND_COLOR="#accdc3" COLOR="#3f4015" CREATED="1789082726792" ID="ID_383248634" MODIFIED="1789082813652" TEXT="Frage im bestehenden Chat nochmal nach — mit konkretem Implementierungs-Szenario">
|
||||
<node BACKGROUND_COLOR="#accdc3" COLOR="#3f4015" CREATED="1789082726792" ID="ID_383248634" MODIFIED="1789082726792" TEXT="Frage im bestehenden Chat nochmal nach — mit konkretem Implementierungs-Szenario">
|
||||
<arrowlink COLOR="#51bbdf" DESTINATION="ID_1161327543" ENDARROW="Default" ENDINCLINATION="231;13;" ID="Arrow_ID_994670578" STARTARROW="None" STARTINCLINATION="-183;-140;"/>
|
||||
<icon BUILTIN="wizard"/>
|
||||
<node CREATED="1789082815287" ID="ID_104427970" MODIFIED="1789082927619" TEXT="beschreibe Registrierung des Scale-Desriptors">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
|
|
@ -85916,11 +85927,19 @@
|
|||
<node CREATED="1789083115404" ID="ID_564486206" MODIFIED="1789083136019" TEXT="Sichtbarkeit der neuen Scale-Definition ⟹ Argument stichhaltig">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#5b280f" CREATED="1789083137852" ID="ID_1965196365" MODIFIED="1789083170965" TEXT="Interne Index-Organisation in der Deque ⟹ nicht durch das Argument gedeckt">
|
||||
<node COLOR="#5b280f" CREATED="1789083137852" ID="ID_1965196365" MODIFIED="1789155688917" TEXT="Interne Index-Organisation in der Deque ⟹ nicht durch das Argument gedeckt">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
<p>
|
||||
während dem Neuhinzufügen könnten Render-Worker concurrent den Index verwenden — hierfür gibt es aber keinerlei Konsistenz-Garantie (nur die Payload Storage-Adressen in der Deque sind garantiert stabil) ⟹ »undefined behaviour«
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="button_cancel"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#accdc3" COLOR="#3f4015" CREATED="1789083189238" ID="ID_735608493" MODIFIED="1789083464492" TEXT="Claude schlägt als Alternative eine globale Index-Tabelle vor, mit atomic-Slots für »Extents«">
|
||||
<node BACKGROUND_COLOR="#accdc3" COLOR="#3f4015" CREATED="1789083189238" ID="ID_735608493" MODIFIED="1789083189238" TEXT="Claude schlägt als Alternative eine globale Index-Tabelle vor, mit atomic-Slots für »Extents«">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
|
|
@ -85933,27 +85952,24 @@
|
|||
address computation touches nothing a writer mutates.
|
||||
</p>
|
||||
<div>
|
||||
<div role="group" aria-label="cpp code" tabindex="0">
|
||||
<div>
|
||||
<div>
|
||||
<pre>
|
||||
<font size="2">class ScaleRegistry
|
||||
<pre><font size="2">
|
||||
class ScaleRegistry
|
||||
{
|
||||
static constexpr size_t CHUNK = 256;
|
||||
static constexpr size_t MAX = 256; // ≙ 65536 scales
|
||||
static constexpr size_t MAX = 256; // &#8793; 65536 scales
|
||||
|
||||
struct Chunk { ScaleDescriptor slot[CHUNK]; };
|
||||
|
||||
std::array<std atomic="#DEFAULT" size="2"><chunk size="2">, MAX> chunk_{};
|
||||
std::mutex writeGuard_; // writers only
|
||||
size_t next_ {0}; // guarded
|
||||
std::array<std atomic="#DEFAULT" size="2"><chunk size="2">, MAX&gt; chunk_{};
|
||||
std::mutex writeGuard_; // writers only
|
||||
size_t next_ {0}; // guarded
|
||||
|
||||
public:
|
||||
ScaleDescriptor const&
|
||||
ScaleDescriptor const&amp;
|
||||
operator[] (ScaleID id) const // lock-free, engine path
|
||||
{
|
||||
return chunk_[id / CHUNK].load (std::memory_order_acquire)
|
||||
->slot[id % CHUNK];
|
||||
-&gt;slot[id % CHUNK];
|
||||
}
|
||||
|
||||
ScaleID
|
||||
|
|
@ -85961,16 +85977,13 @@
|
|||
{
|
||||
std::lock_guard lock{writeGuard_};
|
||||
size_t id = next_++;
|
||||
auto& head = chunk_[id / CHUNK];
|
||||
auto&amp; head = chunk_[id / CHUNK];
|
||||
if (not head.load (std::memory_order_relaxed))
|
||||
head.store (new Chunk{}, std::memory_order_release);
|
||||
head.load (std::memory_order_relaxed)->slot[id % CHUNK] = std::move(def);
|
||||
head.load (std::memory_order_relaxed)-&gt;slot[id % CHUNK] = std::move(def);
|
||||
return ScaleID{id};
|
||||
}
|
||||
};</font></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
|
||||
|
|
@ -85998,6 +86011,7 @@
|
|||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<arrowlink COLOR="#426aa5" DESTINATION="ID_435108847" ENDARROW="Default" ENDINCLINATION="28;-70;" ID="Arrow_ID_1818399541" STARTARROW="None" STARTINCLINATION="-393;12;"/>
|
||||
<icon BUILTIN="wizard"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#accdc3" COLOR="#3f4015" CREATED="1789083492013" ID="ID_816421539" MODIFIED="1789083498973" TEXT="zwei weitere Vorschläge">
|
||||
|
|
@ -86024,6 +86038,10 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1789159365103" ID="ID_435108847" MODIFIED="1789159397705" TEXT="sollte dann wohl gleich eine generische Registry sein...">
|
||||
<linktarget COLOR="#426aa5" DESTINATION="ID_435108847" ENDARROW="Default" ENDINCLINATION="28;-70;" ID="Arrow_ID_1818399541" SOURCE="ID_735608493" STARTARROW="None" STARTINCLINATION="-393;12;"/>
|
||||
<node CREATED="1789159448086" ID="ID_1755995276" MODIFIED="1789159547368" TEXT="Feste Index-Tabelle + heap-allozierte Extents"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
@ -86231,6 +86249,21 @@
|
|||
<icon BUILTIN="hourglass"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1789159639409" ID="ID_654373559" MODIFIED="1789159678163" TEXT="Scale-Eigenschaften abstecken per ParameterScale_test">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1789159687318" ID="ID_1480074646" MODIFIED="1789160197623" TEXT="Hier nur rein die Scale-Descriptoren und das intendierte Verhalten">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
<p>
|
||||
...nicht aber die Registrierung und Einbindung in die Parameter
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<arrowlink COLOR="#852a28" DESTINATION="ID_320664672" ENDARROW="Default" ENDINCLINATION="-765;515;" ID="Arrow_ID_1819779589" STARTARROW="None" STARTINCLINATION="199;8;"/>
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue