Cobrarrow

class COBRArrow(host, port)[source]

COBRArrow is a class that establishes a connection to a gRPC service using Apache Arrow Flight in a Python environment. It provides methods to send and receive data between MATLAB and the Flight server.

COBRArrow(host, port)[source]

Initializes the Python environment and establishes a client connection.

USAGE

obj = COBRArrow (host, port)

INPUTS
  • host – The hostname or IP address of the gRPC server.

  • port – (Optional) The port number on which the gRPC server is running. Default is 50051.

OUTPUT

obj – Instance of the COBRArrow class with an initialized Python environment and established FlightClient connection.

Example

arrowClient = COBRArrow(‘cobrarrow.chatimd.org’); arrowClient = COBRArrow(‘localhost’, 50051);

static MatFieldToPyArrow(fieldData, fieldName)[source]

MatFieldToPyArrow converts a MATLAB struct field to an Apache Arrow record batch.

USAGE

pyArrowRecordBatch = COBRArrow.MatFieldToPyArrow (fieldData, fieldName)

INPUTS
  • fieldData – MATLAB data to be converted.

  • fieldName – Name of the field.

OUTPUT

pyArrowRecordBatch – Converted Apache Arrow record batch.

Example

arrowBatch = MatFieldToPyArrow(data, ‘fieldName’);

DESCRIPTION:

This function converts a MATLAB struct field to an Apache Arrow record batch. It handles different data types including character vectors, numeric vectors, matrices, and cell vectors, and adds metadata to the record batch schema.

The process involves: 1. Determining the data type of the field. 2. Converting the field data to an Apache Arrow record batch. 3. Adding metadata to the schema of the record batch.

The function returns the Apache Arrow record batch with the added metadata.

Example

arrowBatch = COBRArrow.MatFieldToPyArrow(data, ‘fieldName’);

static addMetadata(pyArrowRecordBatch, fieldName, fieldType, fieldDimensions)[source]

addMetadata adds metadata to the schema of a PyArrow record batch.

USAGE

pyArrowRecordBatch = COBRArrow.addMetadata (pyArrowRecordBatch, fieldName)

INPUTS
  • pyArrowRecordBatch – Apache Arrow record batch.

  • fieldName – Name of the field.

OUTPUT

pyArrowRecordBatch – Apache Arrow record batch with metadata.

DESCRIPTION:

This function adds metadata to the schema of a PyArrow record batch. It converts the field name, field type, and field dimensions to Python strings and encodes them as UTF-8. The metadata is then added to the schema of the record batch.

Example

arrowBatch = COBRArrow.addMetadata(arrowBatch, ‘fieldName’);

static arrowToCellVector(pyArrowTable)[source]

arrowToCellVector converts a PyArrow table column to a MATLAB cell vector.

USAGE

fieldData = COBRArrow.arrowToCellVector (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the data.

OUTPUT

fieldData – MATLAB cell vector converted from the PyArrow table column.

DESCRIPTION:

This function handles the conversion of cell vector fields from a PyArrow table to a MATLAB cell vector. It extracts the first column of the PyArrow table, converts the data to a Python list, and then converts each element of the list to a MATLAB character array. The resulting cell array is then transposed to match the expected MATLAB format.

Example

cellVector = COBRArrow.arrowToCellVector(arrowTable);

static arrowToCharVector(pyArrowTable)[source]

arrowToCharVector converts a PyArrow table column to a MATLAB char vector.

USAGE

fieldData = COBRArrow.arrowToCharVector (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the data.

OUTPUT

fieldData – MATLAB char vector converted from the PyArrow table column.

DESCRIPTION:

This function handles the conversion of char vector fields from a PyArrow table to a MATLAB char vector. It extracts the first column of the PyArrow table, converts the data to a Python list, and then converts each element of the list to a MATLAB character array. The resulting char array is then transposed to match the expected MATLAB format.

Example

charVector = COBRArrow.arrowToCharVector(arrowTable);

static arrowToDoubleMatrix(pyArrowTable)[source]

arrowToDoubleMatrix converts a PyArrow table to a MATLAB sparse double matrix.

USAGE

fieldData = COBRArrow.arrowToDoubleMatrix (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the data.

OUTPUT

fieldData – MATLAB sparse double matrix converted from the PyArrow table columns.

DESCRIPTION:

This function converts a PyArrow table to a MATLAB sparse double matrix by extracting row, column, and value data from the table’s columns. It uses the extracted data along with metadata specifying the matrix dimensions to construct a sparse matrix.

Example

sparseMatrix = COBRArrow.arrowToDoubleMatrix(arrowTable);

static arrowToDoubleVector(pyArrowTable)[source]

arrowToDoubleVector converts a PyArrow table column to a MATLAB double vector.

USAGE

fieldData = COBRArrow.arrowToDoubleVector (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the data.

OUTPUT

fieldData – MATLAB double vector converted from the PyArrow table column.

DESCRIPTION:

This function handles the conversion of double vector fields from a PyArrow table to a MATLAB double vector. It extracts the first column of the PyArrow table, converts the data to a Python list, and then converts it to a MATLAB double array. The resulting double array is then transposed to match the expected MATLAB format.

Example

doubleVector = COBRArrow.arrowToDoubleVector(arrowTable);

static arrowToInt(pyArrowTable)[source]

arrowToInt converts a PyArrow table column to a MATLAB integer.

USAGE

fieldData = COBRArrow.arrowToInt (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the data.

OUTPUT

fieldData – MATLAB integer converted from the PyArrow table column.

DESCRIPTION:

This function handles the conversion of integer fields from a PyArrow table to a MATLAB integer. It extracts the first column of the PyArrow table, converts the data to a Python list, and then converts the first element of the list to a MATLAB integer.

Example

intValue = COBRArrow.arrowToInt(arrowTable);

static arrowToIntVector(pyArrowTable)[source]

arrowToIntVector converts a PyArrow table column to a MATLAB integer vector.

USAGE

fieldData = COBRArrow.arrowToIntVector (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the data.

OUTPUTS

fieldData – MATLAB integer vector converted from the PyArrow table column.

DESCRIPTION:

This function handles the conversion of integer vector fields from a PyArrow table to a MATLAB integer vector. It extracts the first column of the PyArrow table, converts the data to a Python list, and then converts it to a MATLAB int64 array. The resulting integer array is then transposed to match the expected MATLAB format.

Example

intVector = COBRArrow.arrowToIntVector(arrowTable);

static arrowToString(pyArrowTable)[source]

arrowToString converts a PyArrow table column to a MATLAB string.

USAGE

fieldData = COBRArrow.arrowToString (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the data.

OUTPUT

fieldData – MATLAB string converted from the PyArrow table column.

DESCRIPTION:

This function handles the conversion of string fields from a PyArrow table to a MATLAB string. It extracts the first column of the PyArrow table, converts the data to a Python list, and then converts the first element of the list to a MATLAB string.

Example

str = COBRArrow.arrowToString(arrowTable);

static charVectorToArrow(fieldData, fieldName)[source]

charVectorToArrow converts a character vector to an Apache Arrow record batch.

USAGE

pyArrowRecordBatch = COBRArrow.charVectorToArrow (fieldData, fieldName)

INPUTS
  • fieldData – Character vector to be converted.

  • fieldName – Name of the field.

OUTPUT

pyArrowRecordBatch – Apache Arrow record batch containing the character vector.

DESCRIPTION:

This function converts a character vector to an Apache Arrow record batch. It creates a Python list from the character vector and converts it to an Apache Arrow array. The array is then used to create an Apache Arrow record batch with the specified field name.

Example

arrowBatch = COBRArrow.charVectorToArrow(‘example’, ‘fieldName’);

client[source]

The FlightClient object for communication with the server

fetchField(schemaName, fieldName)[source]

Retrieves individual field data from the server using Apache Arrow Flight.

USAGE

fieldData = obj.fetchField (schemaName, fieldName)

INPUTS
  • obj – Instance of the COBRArrow class.

  • schemaName – String representing the schema name used as a prefix for keys.

  • fieldName – String representing the name of the field to be fetched.

OUTPUT

fieldData – Data of the fetched field in MATLAB format.

DESCRIPTION:

This function concatenates the schema name and field name to form a key, creates a FlightDescriptor for the key, and attempts to read the field data from the Flight server. If the data is not found on the server, it tries to load the data from DuckDB. The Arrow table data is then converted to MATLAB format and returned.

If the field does not exist in either the server or DuckDB, an error is raised.

Example

fieldData = arrowClient.fetchField(‘mySchema’, ‘myField’);

fetchModel(schemaName)[source]

Fetches the model data from the server using Apache Arrow Flight.

USAGE

model = obj.fetchModel (schemaName)

INPUTS
  • obj – Instance of the COBRArrow class.

  • schemaName – String representing the schema name used as a prefix for keys.

OUTPUT

model – MATLAB structure containing the fetched model data.

DESCRIPTION:

This function creates an empty MATLAB structure model and retrieves descriptors associated with the given schema name from the server. If no descriptors are found, it attempts to load the data from DuckDB. The function iterates through each descriptor, fetches the corresponding field data, and assigns it to the relevant field in the model structure.

If no data is found in the server or DuckDB, an error is raised.

Example

model = arrowClient.fetchModel(‘mySchema’);

fetchModelForFBAAnalysis(schemaName)[source]

fetchModelForFBAAnalysis reads the necessary fields for FBA analysis from the server.

USAGE

FBAmodel = obj.fetchModelForFBAAnalysis (schemaName)

INPUTS
  • obj – Instance of the COBRArrow class.

  • schemaName – String representing the schema name to read the model from.

OUTPUTS

FBAmodel – Structure containing the fields required for FBA analysis.

DESCRIPTION:

This function reads the required and optional fields for Flux Balance Analysis (FBA) from the server using the provided schema name. It initializes an empty struct and populates it with the necessary fields. If an optional field does not exist, the function continues without error.

Example

FBAmodel = arrowClient.fetchModelForFBAAnalysis(‘mySchema’);

getAllDescriptors(schemaName)[source]

getAllDescriptors retrieves all flight descriptors(unique identifier of the flight) from the server.

USAGE
  • descriptors = obj.getAllDescriptors()

  • descriptors = obj.getAllDescriptors (schemaName)

INPUTS
  • obj – Instance of the FlightClient class.

  • schemaName – (Optional) String representing the schema name to filter flights.

OUTPUT

descriptors – Cell array containing descriptors of available flights.

DESCRIPTION:

This function retrieves all flight descriptors from the server. If a schema name is provided, it filters the descriptors based on the schema name. The function converts the Python list of descriptors to a MATLAB cell array and returns it.

Example

descriptors = arrowClient.getAllDescriptors(); descriptors = arrowClient.getAllDescriptors(‘mySchema’);

static getMetadata(pyArrowTable)[source]

getMetadata extracts the field type from the metadata of a PyArrow table.

USAGE

metadataMap = COBRArrow.getMetadata (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the metadata.

OUTPUT

matFieldType – The field type extracted from the metadata.

DESCRIPTION:

This function extracts metadata from the PyArrow table’s schema and converts it from a Python dictionary to a MATLAB containers.Map object. It then retrieves the field type from this map.

The process involves: 1. Extracting metadata from the PyArrow table schema. 2. Converting the metadata dictionary’s keys and values from Python byte strings

to MATLAB strings.

  1. Creating a MATLAB containers.Map object to manage the metadata.

  2. Accessing the specific property ‘mat_field_type’ to determine the field type.

Example

matFieldType = COBRArrow.getMetadata(pyArrowTable);

listAllFlights(schemaName)[source]

listAllFlights lists all available flights and detailed information from the server.

USAGE
  • flightsList = listAllFlights (obj)

  • flightsList = obj.listAllFlights (schemaName)

INPUTS
  • obj – Instance of the FlightClient class.

  • schemaName – (Optional) String representing the schema name to filter flights.

OUTPUT

flightsList – Cell array containing information about available flights. Each cell contains a struct with the following fields:

  • descriptor: Unique identifier for the flight.

  • total_records: Total number of records in the flight.

  • total_bytes: Total number of bytes in the flight.

  • endpoints: List of endpoints where the flight can be accessed.

  • schema: Schema of the flight, including column names and data types.

  • schema_metadata: Additional metadata associated with the schema, such as table name and description.

DESCRIPTION:

This function retrieves all available flights from the server and returns detailed information about each flight. If a schema name is provided, it filters the flights based on the schema name. The function converts the Python list of flights to a MATLAB cell array and returns it.

Example

flightsList = arrowClient.listAllFlights(); flightsList = arrowClient.listAllFlights(‘mySchema’);

loadFromDuckDB(schemaName)[source]

loadFromDuckDB loads data from DuckDB into the Flight server.

USAGE

obj.loadFromDuckDB (schemaName)

INPUTS
  • obj – Instance of the COBRArrow class.

  • schemaName – String representing the schema name to be loaded from DuckDB.

OUTPUTS

None

DESCRIPTION:

This function triggers the loading of data from a DuckDB database into the Flight server. It constructs a request using the schema name, encodes it into bytes, and sends the request to the server using the Flight RPC protocol.

Example

arrowClient.loadFromDuckDB(‘mySchema’);

login(username, password)[source]

Use username and password to authenticate the user, since the server requires authentication to use some of the services. The server requires authentication to send data, persist data, and to use optimization service.

USAGE

obj = obj.login (username, password)

INPUTS
  • obj – Instance of the COBRArrow class.

  • username – String representing the username for authentication

  • password – String representing the password for authentication

OUTPUT

None

DESCRIPTION:

This function attempts to authenticate the user using the provided username and password. If the authentication is successful, it creates a token for the user and sets the options for the FlightClient object. The options include the token as part of the headers for the Flight RPC calls. If the authentication fails, an error is raised.

Example

arrowClient = arrowClient.login(‘username’, ‘password’);

static matrixToArrow(matrix)[source]

matrixToArrow converts a MATLAB matrix to an Apache Arrow record batch.

USAGE

pyArrowRecordBatch = COBRArrow.matrixToArrow (matrix)

INPUTS

matrix – MATLAB matrix to be converted.

OUTPUT

pyArrowRecordBatch – Apache Arrow record batch containing the matrix data.

DESCRIPTION:

This function converts a MATLAB matrix to an Apache Arrow record batch. It extracts the row, column, and value data from the matrix and converts them to Python lists. The lists are then used to create Apache Arrow arrays, which are combined into a record batch.

Example

arrowBatch = COBRArrow.matrixToArrow(magic(3));

static numericToArrow(fieldData, fieldName)[source]

numericToArrow converts a single numeric value to an Apache Arrow record batch.

USAGE

pyArrowRecordBatch = COBRArrow.numericToArrow (fieldData, fieldName)

INPUTS
  • fieldData – Single numeric value to be converted.

  • fieldName – Name of the field.

OUTPUT

pyArrowRecordBatch – Apache Arrow record batch containing the numeric value.

DESCRIPTION:

This function converts a single numeric value to an Apache Arrow record batch. It creates a Python scalar from the numeric value and converts it to an Apache Arrow array. The array is then used to create an Apache Arrow record batch with the specified field name.

Example

arrowBatch = COBRArrow.numericToArrow(42, ‘fieldName’);

optimizeModel(schemaName, solver)[source]

optimizeModel sends an optimization action to the server and retrieves the result.

USAGE

resultStruct = obj.optimizeModel (schemaName, solver)

INPUTS
  • obj – Instance of the COBRArrow class.

  • schemaName – String representing the schema name to be optimized.

  • solver – Instance of the COBRArrowSolver class.

OUTPUT

resultStruct – Structure containing the optimization results.

DESCRIPTION:

This function performs the following steps: 1. Checks and sets the solver instance, defaulting to ‘GLPK’ if none is provided. 2. Constructs an action body string with schema and solver details. 3. Encodes the action body to bytes and creates a Flight Action. 4. Sends the action to the server and retrieves the result stream. 5. Converts the result stream into a PyArrow Table and then to a MATLAB struct. 6. Handles and converts various data types as necessary.

Example

result = arrowClient.optimizeModel(‘mySchema’, arrowSolver);

options[source]

FlightCallOptions for the FlightClient object, it may include parameters like timeout, write_options, headers, and read_options

static otherVectorToArrow(fieldData, fieldName)[source]

otherVectorToArrow converts a numeric or cell vector to an Apache Arrow record batch.

USAGE

pyArrowRecordBatch = COBRArrow.otherVectorToArrow (fieldData, fieldName)

INPUTS
  • fieldData – Numeric or cell vector to be converted.

  • fieldName – Name of the field.

OUTPUT

pyArrowRecordBatch – Apache Arrow record batch containing the vector data.

DESCRIPTION:

This function converts a numeric or cell vector to an Apache Arrow record batch. It creates a Python list from the vector and converts it to an Apache Arrow array. The array is then used to create an Apache Arrow record batch with the specified field name.

Example

arrowBatch = COBRArrow.otherVectorToArrow([1, 2, 3], ‘fieldName’);

persistModel(schemaName, toOverwrite)[source]

persistModel sends a persist action to the server to save the model.

USAGE

obj.persistModel (schemaName)

INPUTS
  • obj – Instance of the COBRArrow class.

  • schemaName – String representing the schema name to be persisted.

  • toOverwrite – (Optional) Boolean indicating whether to overwrite the model on the server. Default is false.

OUTPUT

None

DESCRIPTION:

This function sends a persist action to the server using Apache Arrow Flight to save the model data. It creates a string representation of the dictionary and converts it to bytes using Python’s encode method. The action is then created and called on the server to save the model.

Example

arrowClient.persistModel(‘mySchema’);

static pyArrowTableToMatField(pyArrowTable)[source]

pyArrowTableToMatField converts a PyArrow table to a MATLAB struct field.

USAGE

fieldData = COBRArrow.pyArrowTableToMatField (pyArrowTable)

INPUTS

pyArrowTable – PyArrow table object containing the data.

OUTPUT

fieldData – MATLAB data converted from the PyArrow table.

DESCRIPTION:

This function checks the type of the field and calls the appropriate helper function to convert the data from a PyArrow table to a MATLAB structure.

Example

fieldData = COBRArrow.pyArrowTableToMatField(arrowTable);

pyarrowFlight[source]

PyArrow Flight library

pyarrowLib[source]

PyArrow library

readFromFlightRpc(descriptor)[source]

Reads data from the server using Flight RPC and converts it to a PyArrow table.

USAGE

pyArrowTable = readFromFlightRpc (obj, descriptor)

INPUTS
  • obj – Instance of the COBRArrow class.

  • descriptor – FlightDescriptor object that describes the data to be read.

OUTPUT

pyArrowTable – PyArrow Table containing the retrieved data.

DESCRIPTION:

This function attempts to retrieve data from the Flight server using the provided descriptor. If the server does not have available endpoints, it raises an error. If endpoints are available, it retrieves the data from the first available endpoint and converts it into a PyArrow table.

Example

arrowTable = arrowClient.readFromFlightRpc(descriptor);

requireAuthentication()[source]

checkLoginStatus checks if the user is authenticated by verifying the options.

USAGE

isAuthenticated = obj.checkLoginStatus()

INPUTS

obj – Instance of the COBRArrow class.

OUTPUT

isAuthenticated – Boolean indicating whether the user is authenticated.

DESCRIPTION:

This function checks if the user is authenticated by verifying the options for the FlightClient object. If the options include a token, the user is considered authenticated. If the options do not include a token, the user is considered unauthenticated.

Example

isAuthenticated = arrowClient.checkLoginStatus();

retrieveFlightData(endpoint)[source]

retrieveFlightData retrieves data from the server using Flight RPC and converts it to a PyArrow table.

USAGE

pyArrowTable = obj.retrieveFlightData (endpoint)

INPUTS
  • obj – Instance of the COBRArrow class.

  • endpoint – Endpoint object representing where the data can be accessed.

OUTPUTS

pyArrowTable – PyArrow Table containing the retrieved data.

DESCRIPTION:
This function retrieves data from the server using the Flight RPC protocol.

It attempts to read all data at once using the provided endpoint. If an error occurs during this process, it reads the data in smaller chunks and combines them into a single PyArrow Table. The function returns the PyArrow Table containing the retrieved data.

Example

arrowTable = arrowClient.retrieveFlightData(endpoint);

sendField(schemaName, fieldName, fieldData, toOverwrite)[source]

sendField Sends individual field data to the server using Apache Arrow Flight.

USAGE

obj.sendField (schemaName, fieldName, fieldData, toOverwrite)

INPUTS
  • obj – Instance of the COBRArrow class.

  • schemaName – String specifying the schema name used as a prefix for the key.

  • fieldName – String representing the name of the field to be sent.

  • fieldData – Data for the field to be sent to the server.

  • toOverwrite – (Optional) Boolean indicating whether to overwrite an existing field on the server. Defaults to false.

OUTPUT

None

DESCRIPTION:

This function performs the following steps: 1. Concatenates the schema name and field name to form a unique key. 2. Creates a FlightDescriptor using the key. 3. Checks if a field with the same key already exists on the server. 4. If the field exists and toOverwrite is false, it raises an error. 5. Converts the field data to Apache Arrow format using the MatFieldToPyArrow method. 6. Sends the field data to the server using Flight RPC via the writeToFlightRpc method.

Examples

% Send a new field with the option to overwrite if it exists arrowClient.sendField(‘mySchema’, ‘myField’, myData, true);

% Send a field without overwriting existing fields arrowClient.sendField(‘mySchema’, ‘myField’, myData);

sendModel(model, schemaName, toPersist, toOverwrite)[source]

sendModel Transmits model data to the server using Apache Arrow Flight. Note : 1. Field subSystems are not sent. 2. Field that has unsupported data type will be sent as an empty field, including struct type. It

will raise a warning.

USAGE

obj.sendModel (model, schemaName, toPersist, toOverwrite)

INPUTS
  • obj – Instance of the COBRArrow class.

  • model – MATLAB structure containing the model data to be sent.

  • schemaName – String specifying the schema name used as a prefix for keys in the data.

  • toPersist – (Optional) Boolean indicating whether to persist the model on the server. Defaults to false.

  • toOverwrite – (Optional) Boolean indicating whether to overwrite an existing model on the server. Defaults to false.

OUTPUT

None

DESCRIPTION:

This function processes each field of the input model structure to: 1. Create a FlightDescriptor for each field (excluding fields named ‘subSystems’ and ‘SetupInfo’). 2. Convert the field data to Apache Arrow format using PyArrow. 3. Send the formatted data to the server via Flight RPC. 4. Optionally, persist the model on the server if toPersist is true. 5. Ensure that the model is not overwritten unless explicitly allowed by toOverwrite.

The function performs the following checks: - If toOverwrite is false and the schema already exists on the server, an error is raised. - If toPersist is true, it attempts to persist the model and handles any potential errors.

Examples

% Send a model with the option to overwrite if it exists arrowClient.sendModel(myModel, ‘mySchema’, true, true);

static unsupportedFieldToArrow(fieldName)[source]

unsupportedFieldToArrow creates an empty Apache Arrow record batch for an unsupported field.

USAGE

pyArrowRecordBatch = COBRArrow.unsupportedFieldToArrow (fieldName)

INPUTS

fieldName – Name of the unsupported field.

OUTPUT

pyArrowRecordBatch – Apache Arrow record batch for the unsupported field.

DESCRIPTION:

This function creates an empty Apache Arrow record batch for an unsupported field. It creates an empty string array and converts it to an Apache Arrow record batch.

Example

arrowBatch = COBRArrow.unsupportedFieldToArrow(‘fieldName’);

writeToFlightRpc(descriptor, pyArrowRecordBatch)[source]

writeToFlightRpc sends a PyArrow record batch to the server using Flight RPC.

USAGE

obj.writeToFlightRpc (descriptor, pyArrowRecordBatch)

INPUTS
  • obj – Instance of the COBRArrow class.

  • descriptor – FlightDescriptor object describing the data.

  • pyArrowRecordBatch – PyArrow RecordBatch to be sent to the server.

DESCRIPTION:

This function sends a PyArrow RecordBatch to the server using the Flight RPC protocol. It writes the batch to the server and closes the writer.

Example

arrowClient.writeToFlightRpc(descriptor, pyArrowRecordBatch);

class COBRArrowSolver(solverName)[source]

COBRArrowSolver is a class for managing solver configurations. It allows setting a solver’s name and managing key-value pairs of parameters required by the solver.

The class provides methods to set, update, remove, and display solver parameters, enabling easy configuration and adjustment of solver settings within MATLAB.

Example usage:

solver = COBRArrowSolver(‘GLPK’); solver = solver.setParameter(‘maxIterations’, 1000); solver.showParameters();

COBRArrowSolver(solverName)[source]

Constructor method to initialize the solver with a name and an empty dictionary for parameters.

INPUT

solverName – A string specifying the name of the solver. It is not case-sensitive. Current supported solvers are ‘GLPK’, ‘Gurobi’, ‘CPLEX’.

OUTPUT

obj – An instance of the COBRArrowSolver class.

clearParameters()[source]

Method to clear all parameters from the solver’s dictionary. This reinitializes the parameters map to an empty state.

OUTPUT

obj – The updated instance of the COBRArrowSolver class with cleared parameters.

name[source]

The name of the solver, e.g., ‘GLPK’

parameters[source]

A dictionary to store solver parameters as key-value pairs

removeParameter(key)[source]

Method to remove a parameter from the solver’s dictionary. The parameter is identified by its key.

INPUT

key – A string specifying the parameter’s key to be removed.

OUTPUT

obj – The updated instance of the COBRArrowSolver class.

setName(solverName)[source]

Method to update the solver’s name.

INPUT

solverName – A string specifying the new name of the solver.

OUTPUT

obj – The updated instance of the COBRArrowSolver class.

setParameter(key, value)[source]

Method to add or update a solver parameter. If the key already exists, its value is updated.

INPUT
  • key – A string specifying the parameter’s key.

  • value – The value associated with the parameter key.

OUTPUT

obj – The updated instance of the COBRArrowSolver class.

showParameters()[source]

Method to display all the solver’s parameters. The parameters are shown as key-value pairs.

OUTPUT

None. This method displays the parameters in the console.

initCobrarrow()[source]

Display MATLAB version