argmin_observer_spectator

Struct SpectatorBuilder

source
pub struct SpectatorBuilder { /* private fields */ }
Expand description

Builder for the Spectator observer

§Example

use argmin_observer_spectator::SpectatorBuilder;

let spectator = SpectatorBuilder::new()
    // Optional: Name the optimization run
    // Default: random UUID.
    .with_name("optimization_run_1")
    // Optional, defaults to 127.0.0.1
    .with_host("127.0.0.1")
    // Optional, defaults to 5498
    .with_port(5498)
    // Choose which metrics should automatically be selected.
    // If omitted, all metrics will be selected.
    .select(&["cost", "best_cost"])
    // Build Spectator observer
    .build();

Implementations§

source§

impl SpectatorBuilder

source

pub fn new() -> Self

Creates a new SpectatorBuilder

source

pub fn with_name<T: AsRef<str>>(self, name: T) -> Self

Set a name the optimization run will be identified with

Defaults to a random UUID.

§Example
let builder = SpectatorBuilder::new().with_name("optimization_run_1");
source

pub fn with_host<T: AsRef<str>>(self, host: T) -> Self

Set the host argmin spectator is running on.

Defaults to 127.0.0.1.

§Example
let builder = SpectatorBuilder::new().with_host("192.168.0.1");
source

pub fn with_port(self, port: u16) -> Self

Set the port Spectator is running on.

Defaults to 5498.

§Example
let builder = SpectatorBuilder::new().with_port(1234);
source

pub fn with_channel_capacity(self, capacity: usize) -> Self

Set the channel capacity

A channel is used to queue messages for sending to Spectator. If the channel capacity is reached backpressure will be applied, effectively blocking the optimization. Defaults to 10000. Decrease this value in case memory consumption is too high and increase the value in case blocking causes negative effects.

§Example
let builder = SpectatorBuilder::new().with_channel_capacity(1000);
source

pub fn select<T: AsRef<str>>(self, metrics: &[T]) -> Self

Define which metrics will be selected in Spectator by default

If none are set, all metrics will be selected and shown. Providing zero or more metrics via select disables all apart from the provided ones. Note that independent of this setting, all data will be sent, and metrics can be selected and deselected via the Spectator GUI.

§Example
let builder = SpectatorBuilder::new().select(&["cost", "best_cost"]);
source

pub fn name(&self) -> &String

Returns the name of the optimization run

§Example
let name = builder.name();
source

pub fn host(&self) -> &String

Returns the host this observer will connect to

§Example
let host = builder.host();
source

pub fn port(&self) -> u16

Returns the port this observer will connect to

§Example
let port = builder.port();
source

pub fn channel_capacity(&self) -> usize

Returns the channel capacity

§Example
let capacity = builder.channel_capacity();
source

pub fn selected(&self) -> &HashSet<String>

Returns the selected metrics

§Example
let selected = builder.selected();
source

pub fn build(self) -> Spectator

Build a Spectator instance from the builder

This initiates the connection to the Spectator instance.

§Example
let spectator = SpectatorBuilder::new().build();

Trait Implementations§

source§

impl Default for SpectatorBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> SendAlias for T

§

impl<T> SyncAlias for T