RsBundle  Check-in [7d4dd3e3ac]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use `c_str_macro` instead of `const-cstr`
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7d4dd3e3ac071553815b6cf4bf7483026064ad20
User & Date: fifr 2017-11-21 20:55:18.592
Context
2017-12-13
22:48
Remove empty lines check-in: 25714ffdea user: fifr tags: trunk
2017-11-21
20:55
Use `c_str_macro` instead of `const-cstr` check-in: 7d4dd3e3ac user: fifr tags: trunk
10:06
Reformat sources using `rustfmt` check-in: 998cbd7227 user: fifr tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Cargo.toml.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[package]
name = "bundle"
version = "0.4.0"
authors = ["Frank Fischer <frank-fischer@shadow-soft.de>"]

[dependencies]
itertools = "^0.7.2"
libc = "^0.2.6"
failure = "^0.1.0"
failure_derive = "^0.1.0"
log = "^0.3.6"
const-cstr = "^0.2.1"
cplex-sys = "^0.3"

[dev-dependencies]
env_logger = "^0.4.1"











|




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[package]
name = "bundle"
version = "0.4.0"
authors = ["Frank Fischer <frank-fischer@shadow-soft.de>"]

[dependencies]
itertools = "^0.7.2"
libc = "^0.2.6"
failure = "^0.1.0"
failure_derive = "^0.1.0"
log = "^0.3.6"
c_str_macro = "^1.0"
cplex-sys = "^0.3"

[dev-dependencies]
env_logger = "^0.4.1"
Changes to src/lib.rs.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see  <http://www.gnu.org/licenses/>
//

//! Proximal bundle method implementation.

#[macro_use]
extern crate const_cstr;
extern crate failure;
#[macro_use]
extern crate failure_derive;
extern crate itertools;

#[macro_use]
extern crate log;







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see  <http://www.gnu.org/licenses/>
//

//! Proximal bundle method implementation.

#[macro_use]
extern crate c_str_macro;
extern crate failure;
#[macro_use]
extern crate failure_derive;
extern crate itertools;

#[macro_use]
extern crate log;
Changes to src/master/cpx.rs.
11
12
13
14
15
16
17


18
19
20
21
22
23

24
25
26
27
28
29
30
// 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/>
//

//! Master problem implementation using CPLEX.



use {DVector, Minorant, Real};
use master::UnconstrainedMasterProblem;

use cplex_sys as cpx;


use std::ptr;
use std::os::raw::{c_char, c_int};
use std::f64::{self, NEG_INFINITY};
use std::result::Result;
use failure::Error;

/// A solver error.







>
>






>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 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/>
//

//! Master problem implementation using CPLEX.

#![allow(unused_unsafe)]

use {DVector, Minorant, Real};
use master::UnconstrainedMasterProblem;

use cplex_sys as cpx;

use std;
use std::ptr;
use std::os::raw::{c_char, c_int};
use std::f64::{self, NEG_INFINITY};
use std::result::Result;
use failure::Error;

/// A solver error.
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
impl CplexMaster {
    fn init_qp(&mut self) -> Result<(), Error> {
        if !self.lp.is_null() {
            trycpx!(cpx::freeprob(cpx::env(), &mut self.lp));
        }
        trycpx!({
            let mut status = 0;
            self.lp = cpx::createprob(cpx::env(), &mut status, const_cstr!("mcf").as_ptr());
            status
        });

        if self.force_update {
            self.updateinds.clear();
            for inds in &self.min2index {
                self.updateinds.extend(inds.iter());







|







392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
impl CplexMaster {
    fn init_qp(&mut self) -> Result<(), Error> {
        if !self.lp.is_null() {
            trycpx!(cpx::freeprob(cpx::env(), &mut self.lp));
        }
        trycpx!({
            let mut status = 0;
            self.lp = cpx::createprob(cpx::env(), &mut status, c_str!("mcf").as_ptr());
            status
        });

        if self.force_update {
            self.updateinds.clear();
            for inds in &self.min2index {
                self.updateinds.extend(inds.iter());
Changes to src/mcf/solver.rs.
10
11
12
13
14
15
16


17
18
19
20

21
22
23
24
25
26
27
// 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 {DVector, Real};

use cplex_sys as cpx;


use std::ptr;
use std::ffi::CString;
use std::result::Result;

use std::os::raw::{c_char, c_double, c_int};

use failure::{err_msg, Error};







>
>




>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 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/>
//

#![allow(unused_unsafe)]

use {DVector, Real};

use cplex_sys as cpx;

use std;
use std::ptr;
use std::ffi::CString;
use std::result::Result;

use std::os::raw::{c_char, c_double, c_int};

use failure::{err_msg, Error};
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
        let mut status: c_int;
        let mut net = ptr::null_mut();
        let logfile;

        unsafe {
            #[cfg_attr(feature = "cargo-clippy", allow(never_loop))]
            loop {
                logfile = cpx::fopen(
                    const_cstr!("mcf.cpxlog").as_ptr(),
                    const_cstr!("w").as_ptr(),
                );
                if logfile.is_null() {
                    return Err(err_msg("Can't open log-file"));
                }
                status = cpx::setlogfile(cpx::env(), logfile);
                if status != 0 {
                    break;
                }

                net = cpx::NETcreateprob(cpx::env(), &mut status, const_cstr!("mcf").as_ptr());
                if status != 0 {
                    break;
                }
                status = cpx::NETaddnodes(cpx::env(), net, nnodes as c_int, ptr::null(), ptr::null());
                if status != 0 {
                    break;
                }







|
<
<
<








|







49
50
51
52
53
54
55
56



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
        let mut status: c_int;
        let mut net = ptr::null_mut();
        let logfile;

        unsafe {
            #[cfg_attr(feature = "cargo-clippy", allow(never_loop))]
            loop {
                logfile = cpx::fopen(c_str!("mcf.cpxlog").as_ptr(), c_str!("w").as_ptr());



                if logfile.is_null() {
                    return Err(err_msg("Can't open log-file"));
                }
                status = cpx::setlogfile(cpx::env(), logfile);
                if status != 0 {
                    break;
                }

                net = cpx::NETcreateprob(cpx::env(), &mut status, c_str!("mcf").as_ptr());
                if status != 0 {
                    break;
                }
                status = cpx::NETaddnodes(cpx::env(), net, nnodes as c_int, ptr::null(), ptr::null());
                if status != 0 {
                    break;
                }