RsBundle  Diff

Differences From Artifact [775ddf0f88]:

  • File src/master/master.rs — part of check-in [814bd7230a] at 2016-10-05 16:54:25 on branch trunk — Add problem update callback. (user: fifr size: 4038)

To Artifact [a8283bd00a]:

  • File src/master/base.rs — part of check-in [f0ef5ba392] at 2017-01-20 09:19:39 on branch trunk — Refactor several lint warnings. (user: fifr size: 4030)
  • File src/master/master.rs — part of check-in [2bc4277460] at 2016-10-19 07:37:56 on branch trunk — Run `rustfmt` on all sources. (user: fifr size: 4030)

1
2
3

4
5
6
7
8

9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
/*
 * Copyright (c) 2016 Frank Fischer <frank-fischer@shadow-soft.de>
 *

 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *

 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see  <http://www.gnu.org/licenses/>
 */

use {Real, DVector, Minorant};

use std::error;
use std::result;

quick_error! {
<
|
<
>
|
|
|
|
<
>
|
|
|
|
<
>
|
|
|








1

2
3
4
5
6

7
8
9
10
11

12
13
14
15
16
17
18
19
20
21
22

// Copyright (c) 2016 Frank Fischer <frank-fischer@shadow-soft.de>

//
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.

//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.

//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see  <http://www.gnu.org/licenses/>
//

use {Real, DVector, Minorant};

use std::error;
use std::result;

quick_error! {
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72


/// Result type for master problems.
pub type Result<T> = result::Result<T, Error>;

pub trait MasterProblem {
    /// Unique index for a minorant.
    type MinorantIndex : Copy + Eq;

    /// Set the number of subproblems.
    fn set_num_subproblems(&mut self, n : usize) -> Result<()>;

    /// Set the lower and upper bounds of the variables.
    fn set_vars(&mut self, nvars: usize, lb : Option<DVector>, ub: Option<DVector>);

    /// Return the current number of minorants of subproblem `fidx`.
    fn num_minorants(&self, fidx : usize) -> usize;

    /// Return the current weight of the quadratic term.
    fn weight(&self) -> Real;

    /// Set the weight of the quadratic term, must be > 0.
    fn set_weight(&mut self, weight: Real);

    /// Set the maximal number of inner iterations.
    fn set_max_updates(&mut self, max_updates: usize);

    /// Return the current number of inner iterations.
    fn cnt_updates(&self) -> usize;

    /// Add some variables with bounds.
    fn add_vars(&mut self, bounds: &[(Real,Real)], extend_subgradient: &mut FnMut(usize, Self::MinorantIndex, &[usize]) -> DVector);

    /// Add a new minorant to the model.
    ///
    /// The function returns a unique (among all minorants of all
    /// subproblems) index of the minorant. This index must remain
    /// valid until the minorant is aggregated.
    fn add_minorant(&mut self, fidx: usize, minorant: Minorant) -> Result<Self::MinorantIndex>;







|


|


|


|














|







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71


/// Result type for master problems.
pub type Result<T> = result::Result<T, Error>;

pub trait MasterProblem {
    /// Unique index for a minorant.
    type MinorantIndex: Copy + Eq;

    /// Set the number of subproblems.
    fn set_num_subproblems(&mut self, n: usize) -> Result<()>;

    /// Set the lower and upper bounds of the variables.
    fn set_vars(&mut self, nvars: usize, lb: Option<DVector>, ub: Option<DVector>);

    /// Return the current number of minorants of subproblem `fidx`.
    fn num_minorants(&self, fidx: usize) -> usize;

    /// Return the current weight of the quadratic term.
    fn weight(&self) -> Real;

    /// Set the weight of the quadratic term, must be > 0.
    fn set_weight(&mut self, weight: Real);

    /// Set the maximal number of inner iterations.
    fn set_max_updates(&mut self, max_updates: usize);

    /// Return the current number of inner iterations.
    fn cnt_updates(&self) -> usize;

    /// Add some variables with bounds.
    fn add_vars(&mut self, bounds: &[(Real, Real)], extend_subgradient: &mut FnMut(usize, Self::MinorantIndex, &[usize]) -> DVector);

    /// Add a new minorant to the model.
    ///
    /// The function returns a unique (among all minorants of all
    /// subproblems) index of the minorant. This index must remain
    /// valid until the minorant is aggregated.
    fn add_minorant(&mut self, fidx: usize, minorant: Minorant) -> Result<Self::MinorantIndex>;
99
100
101
102
103
104
105
106
107
108
109
110

    /// Return $\\|g^\*\\|_2\^2$.
    ///
    /// $g\^*$ is the optimal aggregated subgradient.
    fn get_dualoptnorm2(&self) -> Real;

    /// Return the multiplier associated with a minorant.
    fn multiplier(&self, min : Self::MinorantIndex) -> Real;

    /// Move the center of the master problem to $\alpha \cdot d$.
    fn move_center(&mut self, alpha: Real, d: &DVector);
}







|




98
99
100
101
102
103
104
105
106
107
108
109

    /// Return $\\|g^\*\\|_2\^2$.
    ///
    /// $g\^*$ is the optimal aggregated subgradient.
    fn get_dualoptnorm2(&self) -> Real;

    /// Return the multiplier associated with a minorant.
    fn multiplier(&self, min: Self::MinorantIndex) -> Real;

    /// Move the center of the master problem to $\alpha \cdot d$.
    fn move_center(&mut self, alpha: Real, d: &DVector);
}