Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Update to cplex-sys 0.4 and Cplex 12.8 |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
fb204410e17b8f920e347a7dea618df5 |
| User & Date: | fifr 2018-03-08 14:55:15.093 |
Context
|
2018-06-06
| ||
| 20:16 | Remove old rustfmt option check-in: ee5b7dfbc5 user: fifr tags: trunk | |
|
2018-03-08
| ||
| 14:55 | Update to cplex-sys 0.4 and Cplex 12.8 check-in: fb204410e1 user: fifr tags: trunk | |
|
2018-01-26
| ||
| 20:50 | Update dependency on env_logger to v0.5.3 check-in: 886776eee6 user: fifr tags: 0.4.1, trunk | |
Changes
Changes to Cargo.toml.
1 2 3 4 5 6 7 8 9 10 11 12 | [package] name = "bundle" version = "0.4.1" 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.4" c_str_macro = "^1.0" | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | [package] name = "bundle" version = "0.4.1" 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.4" c_str_macro = "^1.0" cplex-sys = "^0.4" [dev-dependencies] env_logger = "^0.5.3" |
Changes to src/mcf/solver.rs.
|
| | | 1 2 3 4 5 6 7 8 | // Copyright (c) 2016, 2017, 2018 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 |
| ︙ | ︙ | |||
23 24 25 26 27 28 29 |
use std;
use std::ptr;
use std::ffi::CString;
use std::result::Result;
use std::os::raw::{c_char, c_double, c_int};
| | < < < < < < < | > > > > | 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 51 52 53 54 55 56 57 58 59 60 61 62 63 |
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::Error;
pub struct Solver {
net: *mut cpx::Net,
}
impl Drop for Solver {
fn drop(&mut self) {
unsafe {
cpx::NETfreeprob(cpx::env(), &mut self.net);
}
}
}
impl Solver {
pub fn new(nnodes: usize) -> Result<Solver, Error> {
let mut status: c_int;
let mut net = ptr::null_mut();
unsafe {
#[cfg_attr(feature = "cargo-clippy", allow(never_loop))]
loop {
status = cpx::setlogfilename(
cpx::env(),
c_str!("mcf.cpxlog").as_ptr(),
c_str!("w").as_ptr(),
);
if status != 0 {
break;
}
net = cpx::NETcreateprob(cpx::env(), &mut status, c_str!("mcf").as_ptr());
if status != 0 {
break;
|
| ︙ | ︙ | |||
78 79 80 81 82 83 84 |
if status != 0 {
let msg = CString::new(vec![0; cpx::MESSAGE_BUF_SIZE])
.unwrap()
.into_raw();
cpx::geterrorstring(cpx::env(), status, msg);
cpx::NETfreeprob(cpx::env(), &mut net);
| < | < < < | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
if status != 0 {
let msg = CString::new(vec![0; cpx::MESSAGE_BUF_SIZE])
.unwrap()
.into_raw();
cpx::geterrorstring(cpx::env(), status, msg);
cpx::NETfreeprob(cpx::env(), &mut net);
return Err(cpx::CplexError {
code: status,
msg: CString::from_raw(msg).to_string_lossy().into_owned(),
}.into());
}
}
Ok(Solver { net: net })
}
pub fn num_nodes(&self) -> usize {
unsafe { cpx::NETgetnumnodes(cpx::env(), self.net) as usize }
}
pub fn num_arcs(&self) -> usize {
|
| ︙ | ︙ |