Pickhardt payments simulation
in this PR I introduce a notebook that showcases how one may do Pickhardt Payments (which are according to the notebook defined as: Using probabilistic payment delivery in a round based payment loop that updeates our belief of the remote liquidity in the uncertainty network and generates reliable and cheap payment flows in every round by solving a piece wise linearized min integer cost flow problem with a seperable cost function. The notebook contains an extensive glossary of terms and derives quite a bit of the theory around probabilistic payment deliver, min cost flow problems, piecewise linearized cost functions and already addresses missing points like proper feature engineering or pruning (Where it currently even ueses arbitrarily chosen numbers to showcase a point)
It consists mainly of 7 classes and is currently best compatible to use with the output of lightning-cli listchannels.
- Channel
- UncertaintyChanel
- OracleChannel
- ChannelGraph
- UncertaintyNetwork
- OracleLightningNetwork
- PaymentSession
The runtime of the solver on the pruned problem is quite fast (consistantly below 100ms) as demanded by some lightning developers. However the code itself is quite slow as it uses networkx as a third party library to store the ChannelGraph, the UncertaintyNetwork and the OracleLightningNetwork. The only other third party dependency that is being used is the google ortools library that ships an highly efficient c++ based min cost flow solver for min integer cost flow problems via a cost scaling algorithm.
The main questions that I have for reviewers:
- Does the data flow and class design make sense?
- Is the naming reasonable?
- should there anything be refactored?
- What would be needed to provide these classes as a module?
- Can one understand what is happening or should one actually communicate this differently? What additional material would help you?
- and of course most importantly semantic errors in case I messed up the conditional probabilities while handling inflight htlcs when maintaining the uncertainty network and making payments. (just realizing one thing that I ignore is to update the uncertainty of the backwords channels. Technically in followup rounds or with successive payments they should play an important role)
Thanks to anyone who will be helping