Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Use `cplex-sys` crate for interfacing with cplex. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
b318be645a81709d708350fc47d9b270 |
| User & Date: | fifr 2017-03-16 14:57:33.443 |
Context
|
2017-03-16
| ||
| 15:06 | Remove build script. check-in: 8a75c0bcc8 user: fifr tags: trunk | |
| 14:57 | Use `cplex-sys` crate for interfacing with cplex. check-in: b318be645a user: fifr tags: trunk | |
| 14:04 | Satisfy some clippy warnings. check-in: 4adb6c3b41 user: fifr tags: trunk | |
Changes
Changes to Cargo.toml.
1 2 3 4 5 | [package] name = "bundle" version = "0.3.0" authors = ["Frank Fischer <frank-fischer@shadow-soft.de>"] | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[package]
name = "bundle"
version = "0.3.0"
authors = ["Frank Fischer <frank-fischer@shadow-soft.de>"]
#build = "build.rs"
[dependencies]
libc = "^0.2.6"
quick-error = "^1.1.0"
log = "^0.3.6"
cplex-sys = { version = "^0.1", path = "../cplex-sys" }
[dev-dependencies]
env_logger = "^0.4.1"
|
Changes to examples/mmcf.rs.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2016, 2017 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 |
| ︙ | ︙ |
Deleted src/cplex.rs.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/lib.rs.
| ︙ | ︙ | |||
30 31 32 33 34 35 36 |
macro_rules! dvec {
( $ elem : expr ; $ n : expr ) => { DVector(vec![$elem; $n]) };
( $ ( $ x : expr ) , * ) => { DVector(vec![$($x),*]) };
( $ ( $ x : expr , ) * ) => { DVector(vec![$($x,)*]) };
}
#[macro_use]
| | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
macro_rules! dvec {
( $ elem : expr ; $ n : expr ) => { DVector(vec![$elem; $n]) };
( $ ( $ x : expr ) , * ) => { DVector(vec![$($x),*]) };
( $ ( $ x : expr , ) * ) => { DVector(vec![$($x,)*]) };
}
#[macro_use]
extern crate cplex_sys;
pub mod vector;
pub use vector::{DVector, Vector};
pub mod minorant;
pub use minorant::Minorant;
|
| ︙ | ︙ |
Changes to src/master/cpx.rs.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 |
//
//! Master problem implementation using CPLEX.
use {Real, DVector, Minorant};
use master::UnconstrainedMasterProblem;
| < | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
//
//! Master problem implementation using CPLEX.
use {Real, DVector, Minorant};
use master::UnconstrainedMasterProblem;
use cplex_sys::*;
use std::result;
use std::ffi::CString;
use std::ptr;
use libc::{c_char, c_int};
use std::f64::NEG_INFINITY;
use std::f64;
|
| ︙ | ︙ | |||
46 47 48 49 50 51 52 |
}
}
}
pub type Result<T> = result::Result<T, Error>;
pub struct CplexMaster {
| | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
}
}
}
pub type Result<T> = result::Result<T, Error>;
pub struct CplexMaster {
lp: *mut CPXLp,
/// True if the QP must be updated.
force_update: bool,
/// List of free minorant indices.
freeinds: Vec<usize>,
|
| ︙ | ︙ | |||
110 111 112 113 114 115 116 |
}
fn num_subproblems(&self) -> usize {
self.minorants.len()
}
fn set_num_subproblems(&mut self, n: usize) -> Result<()> {
| | | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
}
fn num_subproblems(&self) -> usize {
self.minorants.len()
}
fn set_num_subproblems(&mut self, n: usize) -> Result<()> {
trycpx!(CPXsetintparam(env(), Param::Qpmethod.to_c(), Alg::Barrier.to_c()));
trycpx!(CPXsetdblparam(env(), Param::Barepcomp.to_c(), 1e-12));
self.min2index = vec![vec![]; n];
self.index2min.clear();
self.freeinds.clear();
self.minorants = vec![vec![]; n];
self.opt_mults = vec![dvec![]; n];
|
| ︙ | ︙ |
Changes to src/mcf/solver.rs.
| ︙ | ︙ | |||
12 13 14 15 16 17 18 |
//
// 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};
| < | | | | | | 12 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 51 52 53 54 55 56 57 |
//
// 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};
use cplex_sys::*;
use std::ptr;
use std::ffi::CString;
use std::result;
use libc::{c_char, c_int, c_double, FILE};
quick_error! {
#[derive(Debug)]
pub enum Error {
Cplex(err: CplexError) {
cause(err)
description(err.description())
display("{}", err)
from()
}
}
}
pub type Result<T> = result::Result<T, Error>;
pub struct Solver {
net: *mut CPXNet,
logfile: *mut FILE,
}
impl Drop for Solver {
fn drop(&mut self) {
unsafe {
CPXNETfreeprob(env(), &mut self.net);
CPXfclose(self.logfile);
}
}
}
fn clit(s: &'static str) -> *const c_char {
s.as_ptr() as *const c_char
|
| ︙ | ︙ | |||
84 85 86 87 88 89 90 |
if status != 0 {
break;
}
status = CPXNETaddnodes(env(), net, nnodes as c_int, ptr::null(), ptr::null());
if status != 0 {
break;
}
| | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
if status != 0 {
break;
}
status = CPXNETaddnodes(env(), net, nnodes as c_int, ptr::null(), ptr::null());
if status != 0 {
break;
}
status = CPXNETchgobjsen(env(), net, ObjectiveSense::Minimize.to_c());
if status != 0 {
break;
}
break;
}
if status != 0 {
let msg = CString::new(vec![0; MESSAGE_BUF_SIZE]).unwrap().into_raw();
CPXgeterrorstring(env(), status, msg);
CPXNETfreeprob(env(), &mut net);
CPXfclose(logfile);
return Err(Error::Cplex(CplexError {
code: status,
msg: CString::from_raw(msg).to_string_lossy().into_owned(),
}));
|
| ︙ | ︙ |