Table of Contents

Class StudySummary

Namespace
OptunaSharp
Assembly
OptunaSharp.dll

Basic attributes and aggregated results of a Study. Port of optuna/study/_study_summary.py: StudySummary.

See also GetAllStudySummaries(BaseStorage, bool).

public class StudySummary : IEquatable<StudySummary>, IComparable<StudySummary>
Inheritance
StudySummary
Implements
Inherited Members

Constructors

StudySummary(string, StudyDirection?, FrozenTrial?, OrderedDict<string, object?>, int, DateTime?, int, IEnumerable<StudyDirection>?)

Builds a study record from persisted metadata and objective directions.

public StudySummary(string studyName, StudyDirection? direction, FrozenTrial? bestTrial, OrderedDict<string, object?> userAttrs, int nTrials, DateTime? datetimeStart, int studyId, IEnumerable<StudyDirection>? directions = null)

Parameters

studyName string

Name identifying the study in the selected storage.

direction StudyDirection?

Single objective direction; ignored when a directions sequence is supplied.

bestTrial FrozenTrial

Best single-objective trial, or null when unavailable or deliberately omitted.

userAttrs OrderedDict<string, object>

User metadata; values should be JSON serializable for persistent storage.

nTrials int

Number of trials represented by this summary.

datetimeStart DateTime?

Local start time, or null when the trial or study has not started.

studyId int

Storage identifier of the study; distinct from its name.

directions IEnumerable<StudyDirection>

Objective directions in the same order as the objective values.

Remarks

Directions are materialized; supplied attribute dictionaries and any best-trial object are retained by reference.

Exceptions

ValueError

Neither direction nor directions is supplied.

Properties

BestTrial

FrozenTrial with best objective value in the Study.

public FrozenTrial? BestTrial { get; }

Property Value

FrozenTrial

DatetimeStart

Datetime where the Study started.

public DateTime? DatetimeStart { get; }

Property Value

DateTime?

Direction

StudyDirection of the study. Only available during single-objective optimization.

public StudyDirection Direction { get; }

Property Value

StudyDirection

Exceptions

RuntimeError

There is more than one objective direction.

ArgumentOutOfRangeException

The directions collection is empty.

Directions

A sequence of StudyDirection objects.

public IReadOnlyList<StudyDirection> Directions { get; }

Property Value

IReadOnlyList<StudyDirection>

NTrials

The number of trials ran in the Study.

public int NTrials { get; }

Property Value

int

StudyName

Name of the Study.

public string StudyName { get; }

Property Value

string

UserAttrs

Dictionary that contains the attributes of the study set with SetUserAttr(string, object?).

public OrderedDict<string, object?> UserAttrs { get; }

Property Value

OrderedDict<string, object>

Methods

CompareTo(StudySummary?)

Python lt / le: StudySummary is ordered by study id.

public int CompareTo(StudySummary? other)

Parameters

other StudySummary

Study record to compare by identifier; null sorts before this instance.

Returns

int

Negative, zero, or positive according to study identifier order; null sorts first.

Equals(StudySummary?)

Python eq: value equality over every field (Optuna compares other.dict == self.dict) — study name, directions, best trial, user attributes, trial count, start datetime and study id.

public bool Equals(StudySummary? other)

Parameters

other StudySummary

Value to compare with this instance; null compares unequal.

Returns

bool

True when the other value has the same type and equal recorded fields.

Equals(object?)

Compares the fields participating in value equality.

public override bool Equals(object? obj)

Parameters

obj object

Object to compare with this instance.

Returns

bool

True when the other value has the same type and equal recorded fields.

GetHashCode()

A hash consistent with Equals(StudySummary?). Optuna's StudySummary is actually unhashable (it defines eq without hash), but — as with the FrozenTrial port — we expose a usable hash rather than replicate that.

public override int GetHashCode()

Returns

int

Hash code consistent with this type's equality contract.

Operators

operator ==(StudySummary?, StudySummary?)

Applies the == comparison using the type's value equality.

public static bool operator ==(StudySummary? left, StudySummary? right)

Parameters

left StudySummary

Left operand of the comparison.

right StudySummary

Right operand of the comparison.

Returns

bool

True when the comparison holds.

operator >(StudySummary, StudySummary)

Applies the > comparison by study identifier.

public static bool operator >(StudySummary left, StudySummary right)

Parameters

left StudySummary

Left operand of the comparison.

right StudySummary

Right operand of the comparison.

Returns

bool

True when the comparison holds.

operator >=(StudySummary, StudySummary)

Applies the >= comparison by study identifier.

public static bool operator >=(StudySummary left, StudySummary right)

Parameters

left StudySummary

Left operand of the comparison.

right StudySummary

Right operand of the comparison.

Returns

bool

True when the comparison holds.

operator !=(StudySummary?, StudySummary?)

Applies the != comparison using the type's value equality.

public static bool operator !=(StudySummary? left, StudySummary? right)

Parameters

left StudySummary

Left operand of the comparison.

right StudySummary

Right operand of the comparison.

Returns

bool

True when the comparison holds.

operator <(StudySummary, StudySummary)

Applies the < comparison by study identifier.

public static bool operator <(StudySummary left, StudySummary right)

Parameters

left StudySummary

Left operand of the comparison.

right StudySummary

Right operand of the comparison.

Returns

bool

True when the comparison holds.

operator <=(StudySummary, StudySummary)

Applies the <= comparison by study identifier.

public static bool operator <=(StudySummary left, StudySummary right)

Parameters

left StudySummary

Left operand of the comparison.

right StudySummary

Right operand of the comparison.

Returns

bool

True when the comparison holds.