#![allow(clippy::unreadable_literal)]
#[cfg(feature = "baron")]
fn main() -> Result<(), Box<dyn std::error::Error>> {
use oximo::prelude::*;
use oximo::solvers::Baron;
use std::time::Duration;
let m = Model::new("robot");
let x1 = m.var("x1").lb(-1.0).ub(1.0).build();
let x2 = m.var("x2").lb(-1.0).ub(1.0).build();
let x3 = m.var("x3").lb(-1.0).ub(1.0).build();
let x4 = m.var("x4").lb(-1.0).ub(1.0).build();
let x5 = m.var("x5").lb(-1.0).ub(1.0).build();
let x6 = m.var("x6").lb(-1.0).ub(1.0).build();
let x7 = m.var("x7").lb(-1.0).ub(1.0).build();
let x8 = m.var("x8").lb(-1.0).ub(1.0).build();
m.constraint(
"e1",
(0.004731 * x1 * x3 - 0.1238 * x1 - 0.3578 * x2 * x3 - 0.001637 * x2 - 0.9338 * x4 + x7)
.eq(0.3571),
);
m.constraint(
"e2",
(0.2238 * x1 * x3 + 0.2638 * x1 + 0.7623 * x2 * x3 - 0.07745 * x2 - 0.6734 * x4 - x7)
.eq(0.6022),
);
m.constraint("e3", (x6 * x8 + 0.3578 * x1 + 0.004731 * x2).eq(0.0));
m.constraint("e4", (-0.7623 * x1 + 0.2238 * x2).eq(-0.3461));
m.constraint("e5", (x1.powi(2) + x2.powi(2)).eq(1.0));
m.constraint("e6", (x3.powi(2) + x4.powi(2)).eq(1.0));
m.constraint("e7", (x5.powi(2) + x6.powi(2)).eq(1.0));
m.constraint("e8", (x7.powi(2) + x8.powi(2)).eq(1.0));
let opts =
BaronOptions::default().time_limit(Duration::from_secs(120)).num_sol(20).verbose(true);
let result = Baron::new().solve(&m, &opts)?;
println!("status = {:?}", result.status);
for (name, x) in [
("x1", x1),
("x2", x2),
("x3", x3),
("x4", x4),
("x5", x5),
("x6", x6),
("x7", x7),
("x8", x8),
] {
println!(" {name} = {:?}", result.value_of(x));
}
Ok(())
}
#[cfg(not(feature = "baron"))]
fn main() {
println!("Enable the BARON backend:");
println!(" cargo run -p oximo --example baron_robot --features baron");
}