You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently, the LP writer/reader doesn't have any round-trip tests.
Describe the solution you'd like
Build models covering senses/bounds/domains/objective names, write to LP string, read back, assert equivalence.
Improves confidence in the reader without needing solvers.
Additional context
This issue is tagged good first issue specifically to help new contributors get hands-on with the codebase and wants to contribute in the long term. Please do not use AI for this issue.
I have been working on this issue and find some other pbs along the way with oximo-io write_lp
You can fix an Integer variable to a non integer value. It does not raise any error + write the infeasible lp
fn integer_var_fixing_to_non_int_bug() {
let m = Model::new("lp_model");
variable!(m, z, Integer);
m.fix(z, 0.3); // We should raise an error
objective!(m, Min, 2 * z);
let dir = PathBuf::from(env!("CARGO_TARGET_TMPDIR"));
write_lp(&m, &mut File::create(dir.join("integer_var_fixing.lp")).expect("create LP file"))
.expect("dump LP");
}
You cannot fix a a Binary variable at all. See line 1040 of oximo-io/src/lp.rs
#[test]
fn binary_var_fixing_to_non_int_bug() {
let m = Model::new("lp_model");
variable!(m, z, Binary);
m.fix(z, 1); // Currently not written due to a loo
objective!(m, Min, 2 * z);
let dir = PathBuf::from(env!("CARGO_TARGET_TMPDIR"));
write_lp(&m, &mut File::create(dir.join("binary_var_fixing.lp")).expect("create LP file"))
.expect("dump LP");
}
will write :
\* OXIMO LP export - model: lp_model *\
Minimize
obj: 2 z
Subject To
Binaries
z
End
You cannot properly fix a semi-integer variable
#[test]
fn semi_continous_var_fixing_to_non_int_bug() {
let m = Model::new("lp_model");
variable!(m, z, SemiContinuous(1));
m.fix(z, 2.0); // We should raise an error
objective!(m, Min, 2 * z);
let dir = PathBuf::from(env!("CARGO_TARGET_TMPDIR"));
write_lp(&m, &mut File::create(dir.join("semi_cont_fixing.lp")).expect("create LP file"))
.expect("dump LP");
}
\* OXIMO LP export - model: lp_model *\
Minimize
obj: 2 z
Subject To
Bounds
1 <= z <= 2
Semi-Continuous
z
End
Hi @NikitaPomies, yes, that would be great, thank you!
Also, it would be nice if you could fix your Git commit config so that you are credited as a contributor.
What behavior do you want for such a case where several bounds are declared for the same variable ? Same question for
smt like (free declaration + bound or bound than free declaration)
fn a_later_bound_declaration_overrides_an_earlier_one() {
let model = read_lp("Minimize\n obj: x\nBounds\n x >= 2\n x >= 1\nEnd\n".as_bytes())
.expect("repeated bounds");
assert!(close(model.variables()[0].lb, 2.0)); -> currently lb would be 1
Xpress would say : '?Warning: Repeated bound at (6.1):. Previous bound ignored.' and keeps the last bound
Highs would silently takes the last one too.
I think we should left it as is and issue a warning.
another issue I found after resuming working on oximo (after a harsh month at work aha 🥲 ).
On a model with indexed variables, the .lp writer produce a .lp file that the reader rejects.
For instance, the following snippet :
use oximo_core::prelude::*;
use oximo_io::{read_lp, to_lp_string};
let model = Model::new("indexed");
variable!(model, 0.0 <= x[i in 0..2] <= 3.0);
constraint!(model, cap[i in 0..2], x[i] <= 2.0);
objective!(model, Min, x[0] + x[1]);
let text = to_lp_string(&model).unwrap();
read_lp(text.as_bytes()).unwrap(); // fails
Thanks for looking into this! I hadn’t realized that IBM’s naming conventions don’t allow square brackets in variable names (though it makes sense).
I think it makes sense to rename variables only during LP export, preserving model names internally. We should reserve existing valid names first (e.g.: If x_0 already exists, the exported x[0] gets a unique suffix). We should also build a single name map keyed by variable ID and use it everywhere (objective, constraints, bounds, domains, etc.). Other invalid characters and/or reserved kwds can be handled through the same mechanism. I remember adding something similar for MPS.
Replacing brackets with "_" would be fine, but I believe using braces is better to preserve the indexed appearance: x[0] -> x{0} x[0,1] -> x{0,1} cap[0] -> cap{0}
I checked and CPLEX allows braces and commas in names.
Another option is x#0#1, which follows CPLEX's documented convention for exporting multidimensional OPL arrays, but I think it’s less readable. What do you think?
I plan to add support for KNITRO in the future, but I don't have a license and knitro-rs is currently unmaintained, so we would have to fork it and update it, if needed.
Given this, I think _ or # would be more appropriate. Which one do you prefer?
yes you are right. I tested and mosek indeed support the braces. Make sense avoiding braces if you plan to integrate knitro. Have you asked for a license btw ?
I would rather use "_" for the index delimiters than #
I got a temporary KNITRO license a while back, but when I started the gurobi-rs fork and sending PRs to the other bindings (IPOPT, SCIP, CPLEX), forking and updating knitro-rs was outside my scope.
Edit: What about x(i_j)? They all support parentheses
Activity
NikitaPomies commentedon Aug 30, 2026
Hello again,
I have been working on this issue and find some other pbs along the way with oximo-io
write_lpYou can fix an Integer variable to a non integer value. It does not raise any error + write the infeasible lp
You cannot fix a a Binary variable at all. See line 1040 of
oximo-io/src/lp.rswill write :
You cannot properly fix a semi-integer variable
Want me to fix that in the same PR ?
GermanHeim commentedon Aug 30, 2026
Hi @NikitaPomies, yes, that would be great, thank you!
Also, it would be nice if you could fix your Git commit config so that you are credited as a contributor.
NikitaPomies commentedon Aug 31, 2026
Hello, my git config should be fixed now.
I made a first PR in #80 to prevent the user fixing variable to non coherent values.
More incoming
NikitaPomies commentedon Sep 7, 2026
Hello @GermanHeim,
Here is another MR fixing a bug I found while working on this issue #92.
Another MR incoming to allow writing a .lp for a model where the user used objective!(model, Feasibility) (currently fails)
and then the rest of the round trip tests.
NikitaPomies commentedon Sep 20, 2026
Hello @GermanHeim
What behavior do you want for such a case where several bounds are declared for the same variable ? Same question for
smt like (free declaration + bound or bound than free declaration)
Xpress would say : '?Warning: Repeated bound at (6.1):. Previous bound ignored.' and keeps the last bound
Highs would silently takes the last one too.
I think we should left it as is and issue a warning.
GermanHeim commentedon Sep 20, 2026
Hi @NikitaPomies,
My preference for oximo would be strict by default, with these rules:
I think we should error instead of applying last-wins. What do you think?
NikitaPomies commentedon Sep 21, 2026
Yes I agree it is more rust oriented and would make oximo stands out from other modelers on that matter.
NikitaPomies commentedon Oct 25, 2026
Hello @GermanHeim,
another issue I found after resuming working on oximo (after a harsh month at work aha 🥲 ).
On a model with indexed variables, the .lp writer produce a .lp file that the reader rejects.
For instance, the following snippet :
would produce :
The reader forbid such variable names as brackets are used to delimit quadratic terms.
What do you think about writing indexed variables using "_" : "x[i, j]" would become "x_i_j" ?
GermanHeim commentedon Oct 25, 2026
Hi @NikitaPomies,
Thanks for looking into this! I hadn’t realized that IBM’s naming conventions don’t allow square brackets in variable names (though it makes sense).
I think it makes sense to rename variables only during LP export, preserving model names internally. We should reserve existing valid names first (e.g.: If
x_0already exists, the exportedx[0]gets a unique suffix). We should also build a single name map keyed by variable ID and use it everywhere (objective, constraints, bounds, domains, etc.). Other invalid characters and/or reserved kwds can be handled through the same mechanism. I remember adding something similar for MPS.Replacing brackets with "_" would be fine, but I believe using braces is better to preserve the indexed appearance:
x[0]->x{0}x[0,1]->x{0,1}cap[0]->cap{0}I checked and CPLEX allows braces and commas in names.
Another option is
x#0#1, which follows CPLEX's documented convention for exporting multidimensional OPL arrays, but I think it’s less readable. What do you think?NikitaPomies commentedon Oct 26, 2026
I like the braces notation. Mosek (and Knitro, dont know if you plan to integrate it) do not support them though. Not a blocking point for you ?
GermanHeim commentedon Oct 26, 2026
MOSEK seems to support it (MOSEK accepts any character as valid for names, except \0, although they specially mention
!"#$%&()/,.;?@_'`|~, so I am not sure); KNITRO does not support them. It also doesn't support commas.I plan to add support for KNITRO in the future, but I don't have a license and knitro-rs is currently unmaintained, so we would have to fork it and update it, if needed.
Given this, I think
_or#would be more appropriate. Which one do you prefer?NikitaPomies commentedon Oct 26, 2026
yes you are right. I tested and mosek indeed support the braces. Make sense avoiding braces if you plan to integrate knitro. Have you asked for a license btw ?
I would rather use "_" for the index delimiters than #
GermanHeim commentedon Oct 26, 2026
Lets go with
_, then.I got a temporary KNITRO license a while back, but when I started the
gurobi-rsfork and sending PRs to the other bindings (IPOPT, SCIP, CPLEX), forking and updating knitro-rs was outside my scope.Edit: What about
x(i_j)? They all support parentheses