|
| | ExplicitClient ()=default |
| | Constructor.
|
| |
| | ~ExplicitClient () noexcept=default |
| | Destructor.
|
| |
| void | ConnectChannel (std::shared_ptr< grpc::ChannelInterface > channel) |
| | Connects the client stub to a gRPC channel.
|
| |
| Variables | ComputeFunction (const Variables &inputs) |
| | Calls the remote analysis server function evaluation via gRPC.
|
| |
| Partials | ComputeGradient (const Variables &inputs) |
| | Calls the remote analysis server gradient evaluation via gRPC.
|
| |
| void | SetStub (std::unique_ptr< ExplicitService::StubInterface > stub) |
| | Set the stub (for testing purposes)
|
| |
| | DisciplineClient () |
| | Construct a new Discipline Client object.
|
| |
| void | ConnectChannel (const std::shared_ptr< grpc::ChannelInterface > &channel) |
| | Connect to a gRPC channel.
|
| |
| void | GetInfo () |
| | Get the discipline info.
|
| |
| void | SendStreamOptions () |
| | Send the stream options to the server.
|
| |
| void | SendOptions (const philote::DisciplineOptions &options) |
| | Send the discipline options to the server.
|
| |
| void | Setup () |
| | Setup the discipline.
|
| |
| void | GetVariableDefinitions () |
| | Get the variable definitions from the server.
|
| |
| void | GetPartialDefinitions () |
| | Get the partial definitions from the server.
|
| |
| std::vector< std::string > | GetVariableNames () |
| | Get the variable names.
|
| |
| VariableMetaData | GetVariableMeta (const std::string &name) |
| | Get the variable meta data.
|
| |
| std::vector< philote::PartialsMetaData > | GetPartialsMeta () |
| | Get the partials meta data.
|
| |
| void | SetStub (std::unique_ptr< philote::DisciplineService::StubInterface > stub) |
| | Set the stub.
|
| |
| const StreamOptions & | GetStreamOptions () const noexcept |
| | Get the stream options.
|
| |
| void | SetStreamOptions (const StreamOptions &options) |
| | Set the stream options.
|
| |
| const DisciplineProperties & | GetProperties () const noexcept |
| | Get the discipline properties.
|
| |
| void | SetProperties (const DisciplineProperties &props) |
| | Set the discipline properties.
|
| |
| const std::vector< VariableMetaData > & | GetVariableMetaAll () const noexcept |
| | Get the variable metadata.
|
| |
| void | SetVariableMeta (const std::vector< VariableMetaData > &meta) |
| | Set the variable metadata.
|
| |
| const std::vector< PartialsMetaData > & | GetPartialsMetaConst () const noexcept |
| | Get the partials metadata (const version)
|
| |
| void | SetPartialsMetaData (const std::vector< PartialsMetaData > &meta) |
| | Set the partials metadata.
|
| |
| void | SetRPCTimeout (std::chrono::milliseconds timeout) |
| | Set the RPC timeout for all client operations.
|
| |
| std::chrono::milliseconds | GetRPCTimeout () const noexcept |
| | Get the current RPC timeout.
|
| |
Client class for calling a remote explicit discipline.
This class may be inherited from or used by MDO framework developers. However, it is a fully functional Philote MDO client.
The ExplicitClient connects to a remote ExplicitDiscipline server via gRPC and provides methods to perform function and gradient evaluations.
- Example: Basic Client Usage
#include <grpcpp/grpcpp.h>
auto channel = grpc::CreateChannel("localhost:50051",
grpc::InsecureChannelCredentials());
inputs.at("x")(0) = 5.0;
inputs.at("y")(0) = -2.0;
std::cout << "f(5, -2) = " << outputs.at("f_xy")(0) << std::endl;
return 0;
}
void GetInfo()
Get the discipline info.
void GetVariableDefinitions()
Get the variable definitions from the server.
void Setup()
Setup the discipline.
Client class for calling a remote explicit discipline.
Definition explicit.h:418
Variables ComputeFunction(const Variables &inputs)
Calls the remote analysis server function evaluation via gRPC.
void ConnectChannel(std::shared_ptr< grpc::ChannelInterface > channel)
Connects the client stub to a gRPC channel.
A class for storing continuous and discrete variables.
Definition variable.h:85
std::map< std::string, philote::Variable > Variables
Definition variable.h:404
int main()
Definition paraboloid_client.cpp:50
- Example: Computing Gradients
double df_dx = gradients[{"f_xy", "x"}](0);
double df_dy = gradients[{"f_xy", "y"}](0);
std::cout << "∂f/∂x = " << df_dx << std::endl;
std::cout << "∂f/∂y = " << df_dy << std::endl;
void GetPartialDefinitions()
Get the partial definitions from the server.
Partials ComputeGradient(const Variables &inputs)
Calls the remote analysis server gradient evaluation via gRPC.
std::map< std::pair< std::string, std::string >, philote::Variable > Partials
Definition variable.h:405
- Example: Complete Client-Server Workflow
auto channel = grpc::CreateChannel("localhost:50051",
grpc::InsecureChannelCredentials());
for (const auto& name : var_names) {
if (meta.type() == philote::kInput) {
inputs[name](0) = 1.0;
}
}
VariableMetaData GetVariableMeta(const std::string &name)
Get the variable meta data.
std::vector< std::string > GetVariableNames()
Get the variable names.
- Note
- Thread Safety: This class is NOT thread-safe. Each thread should create its own ExplicitClient instance. Concurrent calls to ComputeFunction or ComputeGradient on the same instance will cause data races. The underlying gRPC stub is thread-safe, so multiple ExplicitClient instances can safely share a channel.
- See also
- philote::ExplicitDiscipline
-
philote::ImplicitClient