Skip to content

CMapLapParaSolverAPI

Nariaki Tateiwa edited this page Mar 30, 2022 · 1 revision

Table of Contents



Communication with Load Coordinator

iReceiveMessages : API to check messaegs have been received from Load Coordinator

The solver needs to run this function periodically at sufficiently short intervals, for example, 1 second.

void iReceiveMessages()


Sending Objects to Load Coordinator

sendBasis : API for sending lattice basis matrix to LoadCoordinator

  • basis, required -- Lattice basis.
  • enumCost, optional -- Cost of enumeration generated from basis. If this is omitted, it will be calculated as the full enumeration cost in the function.
void sendBasis(
    ParaCMapLAP::BasisMatrix<int> &basis,
    double enumCost=-1
)

sendVectors : API for sending lattice vectors to LoadCoordinator

  • vectors, required -- Matirx including lattice vectors in row major.
void sendVectors(
    ParaCMapLAP::BasisMatrix<int> &vectors
)

sendSolution : API for sending lattice vector to LoadCoordinator

Lattice vectors sent by this API will have priority over other messages.

  • v, required -- A lattice vectors.
  • objValue, required -- Objective value about v.
void sendSolution(
      ParaCMapLAP::LatticeVector<int> &v,
      double objValue
      )

notificationIsNecessary : API for checking if the solver should send a notification message

bool notificationIsNecessary(
        )

Example code in program as solver.

// check to be necessary to send the status
if( cmapLapParaSolver->notificationIsNecessary() )
{
    sendStatus(...);   // send solver satus
}

iReceiveIsNecessary : API for checking if the solver should execute iReceiveMessages function of CMapLapParaSolverAPI

bool iReceiveIsNecessary()

Example code in program as solver.

if( cmapLapParaSolver->iReceiveIsNecessary() )
{
    cmapLapParaSolver->iReceiveMessages();
}

shareVectorsIsNecessary : API for checking if the solver should send lattice vectors to LoadCoordinatoor

// check to share vectors
if( cmapLapParaSolver->shareVectorsIsNecessary() )
{
    // sendVectors <-- create SVP::BasisMatrix matrix includes vectors
    cmapLapParaSolver->sendVectors(sendVectors);
}


Sending Solver Status

APIs for sending the state of the solver depends on lattice algorithms.

BKZ

  • inBasis, required -- current lattice basis.
  • inCurrentBlockSize, required -- currend BKZ block size.
  • inTour, required -- current number of BKZ loop.
  • inElapsedTime, required -- current elapsed time.
 void sendSolverState(
    ParaCMapLAP::BasisMatrix<int>& inBasis,
    int      inCurrentBlockSize,
    int      inTour,
    double   inElapsedTime
    )

Enum

  • inElapsedTime, required -- current elapsed time.
  • inCoeff, required -- coefficients of a current search node
  • inDepth, required -- depth of current searched node
  • inShortestNorm, required -- the shortest norm found
  • inNumSearchedNodes, required -- number of searched nodes in the enumeration tree
 void sendSolverState(
    double   inElapsedTime,
    ParaCMapLAP::LatticeVector<int> &inCoeff,
    int      inDepth,
    double   inEnumCost,
    double   inShortestNorm,
    long int inNumSearchedNodes
    )

Sieve

  • inElapsedTime, required -- current elapsed time.
  • inBlockSize, required -- block size.
  • inNLoop, required -- number of Sieve algorithm loop
  • inListSize, required -- size of List L
  • inStackSize, required -- size of Stack S
  • inMaxListSize, required -- maximum size used by List L
  • inNCollisions, required -- number of collisions
  • inShortestNorm, required -- the shortest norm found
 void sendSolverState(
    double       inElapsedTime
    int          inBlockSize,
    long int     inNLoop,
    int          inListSize,
    int          inStackSize,
    int          inMaxListSize,
    int          inNCollisions,
    double       inShortestNorm
    )



Receiving Objects

hasReceivedBasis : API for checking the solve has received lattice basis matrix from LoadCoordinator

bool hasReceivedBasis()

getReceivedBasis : API for getter of lattice basis matrix solver received from LoadCoordinator

template<typename BasisFloat>
SVP::BasisMatrix<BasisFloat> getReceivedBasis()

requestVectors : API for requesting the lattice vectors to Load Coordinator

Parameters

  • nRequestVectors, required -- number of requested lattice vecotrs
void requestVectors(
    int nRequestVectors
    )

hasReceivedVectors : API for checking the solve has received lattice vectors from LoadCoordinator

Returns

  • bool: true if solver has received vectors from Load Coordinator else false
bool hasReceivedVectors()

getReceivedVectors : API for getter of lattice vectors received from LoadCoordinator

Parameters

  • vectors, requiered -- received vectors

Returns

  • bool: true if number of received vectors is greater than 0 else false
template<typename BasisFloat>
bool getReceivedVectors(
        SVP::BasisMatrix<BasisFloat> &vectors
        )