13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
+
-
-
-
-
|
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
//! An asynchronous first-order oracle.
pub use crate::data::minorant::SubgradientExtender;
use crate::{Aggregatable, DVector, Minorant, Real};
use std::sync::Arc;
/// Channel to send evaluation results to.
pub trait ResultSender<P>: Send
where
P: FirstOrderProblem,
{
type Err: std::error::Error + Send;
/// Send a new objective `value`.
fn objective(&self, value: Real) -> Result<(), Self::Err>;
/// Send a new `minorant` with associated `primal`.
fn minorant(&self, minorant: Minorant<P::Primal>) -> Result<(), Self::Err>;
/// Send an error message.
fn error(&self, err: P::Err) -> Result<(), Self::Err>;
}
/// The subgradient extender is a callback used to update existing minorants
/// given their associated primal data.
pub type SubgradientExtender<P, E> = dyn FnMut(usize, &P, &[usize]) -> Result<DVector, E> + Send;
/// Channel to send problem updates to.
pub trait UpdateSender<P>: Send
where
P: FirstOrderProblem,
{
type Err: std::error::Error + Send;
|