QDpy
Loading...
Searching...
No Matches
qdpy.rl.loki.LOKI Class Reference

Co-design over a finite catalog with local competition and shared PPO policies. More...

Public Member Functions

 pools (self)
 embedding_scale (self)
 cluster_centers (self)
 stats (self)
 observation (self, design, observation)
 Condition a policy input on a design embedding.
 cluster (self, design)
 Assign an unseen design to the nearest learned cluster center.
 train (self, max_env_steps)
 Spend an additional budget in complete round-robin design and PPO updates.
 policy (self, cluster, *, seed=0, device=None)
 Return an independent serializable actor for a cluster.
 evaluate (self, designs=None, *, episodes_per_design=8, seed=1337)
 Audit designs with fresh episodes and their assigned cluster policies.

Detailed Description

Co-design over a finite catalog with local competition and shared PPO policies.

Train one controller and value model per cluster of design embeddings.

A round visits one cluster and takes one on-policy PPO update across
the current design pool. At configured intervals, evaluate uniformly
sampled non-pool designs and incumbents on the current actor using
common seeds. Replace the worst incumbents with the best sampled
designs before training. Each episode sees its design embedding as
part of the observation.

:param designs: Finite ordered catalog of distinct immutable design identifiers.
:param env_factory: Callable (design) returning a fresh single Gymnasium environment.
:param descriptor: Callable (design) returning a real vector for clustering and policy conditioning.
:param clusters: Number of k-means clusters.
:param pool_size: Maximum live designs per cluster.
:param search_period: Rounds per cluster between replacements, or None for static pools.
:param proposals: Maximum new designs measured in a search round.
:param replace_count: Maximum number of incumbents replaced in a search round.
:param evaluation_episodes: Common-seed episodes per design during competition.
:param max_episode_steps: Shared episode horizon.
:param ppo: PPOConfig for the shared actor and critic.
:param policy: PolicyConfig for hidden layers.
:param seed: Private seed for clustering, proposal draws, training, and evaluation.
:param device: PyTorch device.

Definition at line 100 of file loki.py.

Member Function Documentation

◆ cluster()

qdpy.rl.loki.LOKI.cluster ( self,
design )

Assign an unseen design to the nearest learned cluster center.

Parameters
designAny encodable design identifier.
Returns
Zero-based cluster index.
Return the nearest training cluster in normalized embedding space.

Definition at line 219 of file loki.py.

◆ cluster_centers()

qdpy.rl.loki.LOKI.cluster_centers ( self)
Return cluster centers in normalized embedding coordinates.

Definition at line 199 of file loki.py.

◆ embedding_scale()

qdpy.rl.loki.LOKI.embedding_scale ( self)
Return the coordinate divisors to preserve with exported actors.

Definition at line 194 of file loki.py.

◆ evaluate()

qdpy.rl.loki.LOKI.evaluate ( self,
designs = None,
* ,
episodes_per_design = 8,
seed = 1337 )

Audit designs with fresh episodes and their assigned cluster policies.

Parameters
designsOptional ordered audit panel. The default uses the live pools.
episodes_per_designNumber of common-seed episodes per design.
seedPrivate audit seed.
Returns
Independent LOKIEvaluation with the audit cost.
Audit held-out designs by assigning them to the closest training cluster.

Definition at line 306 of file loki.py.

◆ observation()

qdpy.rl.loki.LOKI.observation ( self,
design,
observation )

Condition a policy input on a design embedding.

Parameters
designAny encodable design identifier.
observationRaw observation from the design environment.
Returns
Flat numerical observation accepted by an exported shared actor.
Append the normalized design embedding to the raw observation.

Definition at line 212 of file loki.py.

◆ policy()

qdpy.rl.loki.LOKI.policy ( self,
cluster,
* ,
seed = 0,
device = None )

Return an independent serializable actor for a cluster.

Parameters
clusterZero-based cluster index.
seedSeed for action sampling by the returned actor.
deviceOptional device for the returned actor.
Returns
A ContinuousPolicy or CategoricalPolicy accepting conditioned observations.
Copy the actor's measured weights without its critic or optimizer.

Definition at line 294 of file loki.py.

◆ pools()

qdpy.rl.loki.LOKI.pools ( self)
Return live designs grouped by shared controller index.

Definition at line 189 of file loki.py.

◆ stats()

qdpy.rl.loki.LOKI.stats ( self)
Return cumulative training, design search, and replacement costs.

Definition at line 204 of file loki.py.

◆ train()

qdpy.rl.loki.LOKI.train ( self,
max_env_steps )

Spend an additional budget in complete round-robin design and PPO updates.

Parameters
max_env_stepsHard cap on real training and design-competition environment steps.
Returns
Cumulative LOKIStats.
Reserve the full comparison panel and PPO rollout before starting each round.

Definition at line 258 of file loki.py.


The documentation for this class was generated from the following file: