private void AddRowConstraint(double[] row, lpsolve_constr_types type = lpsolve_constr_types.EQ, double val = 0) { Rows++; if (!LpSolvePointer.add_constraint(row, type, val)) { throw new InvalidOperationException(); } }
/// <summary> /// addConstraint({{0,10},{1,5}}, lpsolve.lpsolve_constr_types.LE, 100) means: /// 10x + 5y <= 100 /// </summary> /// <param name="cfPerVarIdx"> /// Each tuple contains variable index, and it's coefficient in this constraint. /// </param> public void addConstraint(List <Tuple <int, double> > cfPerVarIdx, lpsolve_constr_types constraintType, double rhs) { for (int j = 0; j < cfPerVarIdx.Count; ++j) { colno[j] = 1 + cfPerVarIdx[j].Item1; /* first column */ row[j] = cfPerVarIdx[j].Item2; } /* add the row to lpsolve */ lpsolve.add_constraintex(lp, cfPerVarIdx.Count, row, colno, constraintType, rhs); }
public static extern bool add_lag_con(IntPtr lp, double[] row, lpsolve_constr_types con_type, double rhs);
[DllImport("lpsolve55.dll", SetLastError = true)] public static extern bool set_constr_type(int lp, int row, lpsolve_constr_types con_type);
public static extern bool add_constraint(IntPtr lp, double[] row, lpsolve_constr_types constr_type, double rh);
public bool set_constr_type(int row, lpsolve_constr_types con_type) { return(Interop.set_constr_type(_lp, row, con_type)); }
[DllImport("lpsolve55.dll", SetLastError = true)] public static extern bool add_constraint(int lp, double[] row, lpsolve_constr_types constr_type, double rh);
[DllImport("lpsolve55.dll", SetLastError = true)] public static extern bool str_add_constraint(IntPtr lp, string row_string, lpsolve_constr_types constr_type, double rh);
public bool add_constraintex(int count, double[] row, int[] colno, lpsolve_constr_types constr_type, double rh) { return(Interop.add_constraintex(_lp, count, row, colno, constr_type, rh)); }
public static extern byte set_constr_type(int lp, int row, lpsolve_constr_types con_type);
public static extern byte str_add_constraint(int lp, string row_string, lpsolve_constr_types constr_type, double rh);
public static extern byte add_constraintex(int lp, int count, ref double row, ref int colno, lpsolve_constr_types constr_type, double rh);
public static extern byte add_lag_con(int lp, ref double row, lpsolve_constr_types con_type, double rhs);
internal static extern byte add_constraintex(int lp, int count, double[] row, int[] colno, lpsolve_constr_types constr_type, double rh);
internal static extern byte add_constraint(int lp, double[] row, lpsolve_constr_types constr_type, double rh);
public static extern bool str_add_constraint(IntPtr lp, [MarshalAs(UnmanagedType.LPStr)] string row_string, lpsolve_constr_types constr_type, double rh);
public static extern bool str_add_constraint(IntPtr lp, string row_string, lpsolve_constr_types constr_type, double rh);
public static extern byte str_add_lag_con(int lp, string row_string, lpsolve_constr_types con_type, double rhs);
public static extern bool add_constraint(int lp, ref double row, lpsolve_constr_types constr_type, double rh);
[DllImport("lpsolve55.dll", SetLastError=true)] public static extern bool add_constraintex(int lp, int count, ref double row, ref int colno, lpsolve_constr_types constr_type, double rh);
[DllImport("lpsolve55.dll", SetLastError = true)] public static extern bool add_constraintex(IntPtr lp, int count, double[] row, int[] colno, lpsolve_constr_types constr_type, double rh);
[DllImport("lpsolve55.dll", SetLastError=true)] public static extern bool set_constr_type(int lp, int row, lpsolve_constr_types con_type);
public bool str_add_constraint(string row_string, lpsolve_constr_types constr_type, double rh) { return(Interop.str_add_constraint(_lp, row_string, constr_type, rh)); }
[DllImport("lpsolve55.dll", SetLastError=true)] public static extern bool str_add_lag_con(int lp, string row_string, lpsolve_constr_types con_type, double rhs);
private static string ToFbcString(lpsolve_constr_types op) { switch (op) { case lpsolve_constr_types.LE: return "lessEqual"; case lpsolve_constr_types.EQ: default: return "equal"; case lpsolve_constr_types.GE: return "greaterEqual"; } }
[DllImport("lpsolve55.dll", SetLastError = true)] public static extern bool add_constraintex(int lp, int count, ref double row, ref int colno, lpsolve_constr_types constr_type, double rh);
public LPsolveConstraint(XmlElement item) { _sbmlId = item.GetAttribute("reaction", FluxBalance.STR_FBA_NAMESPACE); _value = Convert.ToDouble(item.GetAttribute("value", FluxBalance.STR_FBA_NAMESPACE)); _Operator = GetOperator(item.GetAttribute("operation", FluxBalance.STR_FBA_NAMESPACE)); }
[DllImport("lpsolve55.dll", SetLastError = true)] public static extern bool str_add_lag_con(int lp, string row_string, lpsolve_constr_types con_type, double rhs);
public LPsolveConstraint(string sbmlId, lpsolve_constr_types sOperator, double value) { _sbmlId = sbmlId; _Operator = sOperator; _value = value; }
public static extern bool add_constraintex(IntPtr lp, int count, double[] row, int[] colno, lpsolve_constr_types constr_type, double rh);
private string GetOperationString(lpsolve_constr_types type) { switch (type) { case lpsolve_constr_types.LE: return "less"; case lpsolve_constr_types.EQ: return "equal"; case lpsolve_constr_types.GE: default: return "greater"; } }
public static extern bool set_constr_type(IntPtr lp, int row, lpsolve_constr_types con_type);
public static extern bool add_lag_con(int lp, ref double row, lpsolve_constr_types con_type, double rhs);
public static extern bool str_add_lag_con(IntPtr lp, string row_string, lpsolve_constr_types con_type, double rhs);
public static extern bool str_add_constraint(int lp, string row_string, lpsolve_constr_types constr_type, double rh);
public static extern bool add_constraintex(int lp, int count, ref double row, ref int colno, lpsolve_constr_types constr_type, double rh);
[DllImport("lpsolve55.dll", SetLastError = true)] public static extern bool add_lag_con(IntPtr lp, double[] row, lpsolve_constr_types con_type, double rhs);
public static extern bool set_constr_type(int lp, int row, lpsolve_constr_types con_type);
public static extern byte str_add_lag_con(IntPtr lp, [MarshalAs(UnmanagedType.LPStr)] string row_string, lpsolve_constr_types con_type, double rhs);
public static extern bool str_add_lag_con(int lp, string row_string, lpsolve_constr_types con_type, double rhs);
public bool add_constraint(double[] row, lpsolve_constr_types constr_type, double rh) { return(Interop.add_constraint(_lp, row, constr_type, rh)); }