use std::fmt::{self, Debug};
use crate::matrix::coo::CooMat;
use crate::problem::lp::ProblemLp;
use crate::problem::nlp::ProblemNlp;
use crate::problem::milp::ProblemMilp;
use crate::problem::minlp::ProblemMinlp;
pub enum Problem {
Minlp(ProblemMinlp),
Milp(ProblemMilp),
Lp(ProblemLp),
Nlp(ProblemNlp),
}
pub type ProblemEval = Box<dyn Fn(&mut f64, // phi
&mut Vec<f64>, // gphi
&mut CooMat<f64>, // Hphi
&mut Vec<f64>, // f
&mut CooMat<f64>, // J
&mut Vec<CooMat<f64>>, // H
&[f64] // x
) -> ()>;
pub struct ProblemSol {
pub x: Vec<f64>,
pub lam: Vec<f64>,
pub nu: Vec<f64>,
pub mu: Vec<f64>,
pub pi: Vec<f64>,
}
impl ProblemSol {
pub fn new(nx: usize, na: usize, nf: usize) -> Self {
Self {
x: vec![0.;nx],
lam: vec![0.;na],
nu: vec![0.;nf],
mu: vec![0.;nx],
pi: vec![0.;nx]
}
}
}
impl Debug for ProblemSol {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ProblemSol")
.field("x", &self.x)
.field("lam", &self.lam)
.field("nu", &self.nu)
.field("mu", &self.mu)
.field("pi", &self.pi)
.finish()
}
}