Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Empty Bounds sections should be allowed #28

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[target.'cfg(all())']
rustflags = [
# From: <https://github.com/EmbarkStudios/rust-ecosystem/blob/main/lints.toml>
"-Dunsafe_code",
"-Wclippy::all",
"-Wclippy::await_holding_lock",
"-Wclippy::char_lit_as_u8",
"-Wclippy::checked_conversions",
"-Wclippy::dbg_macro",
"-Wclippy::debug_assert_with_mut_call",
"-Wclippy::doc_markdown",
"-Wclippy::empty_enum",
"-Wclippy::enum_glob_use",
"-Wclippy::exit",
"-Wclippy::expl_impl_clone_on_copy",
"-Wclippy::explicit_deref_methods",
"-Wclippy::explicit_into_iter_loop",
"-Wclippy::fallible_impl_from",
"-Wclippy::filter_map_next",
"-Wclippy::flat_map_option",
"-Wclippy::float_cmp_const",
"-Wclippy::fn_params_excessive_bools",
"-Wclippy::from_iter_instead_of_collect",
"-Wclippy::if_let_mutex",
"-Wclippy::implicit_clone",
"-Wclippy::imprecise_flops",
"-Wclippy::inefficient_to_string",
"-Wclippy::invalid_upcast_comparisons",
"-Wclippy::large_digit_groups",
"-Wclippy::large_stack_arrays",
"-Wclippy::large_types_passed_by_value",
"-Wclippy::let_unit_value",
"-Wclippy::linkedlist",
"-Wclippy::lossy_float_literal",
"-Wclippy::macro_use_imports",
"-Wclippy::manual_ok_or",
"-Wclippy::map_err_ignore",
"-Wclippy::map_flatten",
"-Wclippy::map_unwrap_or",
"-Wclippy::match_on_vec_items",
"-Wclippy::match_same_arms",
"-Wclippy::match_wild_err_arm",
"-Wclippy::match_wildcard_for_single_variants",
"-Wclippy::mem_forget",
"-Wclippy::mismatched_target_os",
"-Wclippy::missing_enforced_import_renames",
"-Wclippy::mut_mut",
"-Wclippy::mutex_integer",
"-Wclippy::needless_borrow",
"-Wclippy::needless_continue",
"-Wclippy::needless_for_each",
"-Wclippy::option_option",
"-Wclippy::path_buf_push_overwrite",
"-Wclippy::ptr_as_ptr",
"-Wclippy::rc_mutex",
"-Wclippy::ref_option_ref",
"-Wclippy::rest_pat_in_fully_bound_structs",
"-Wclippy::same_functions_in_if_condition",
"-Wclippy::semicolon_if_nothing_returned",
"-Wclippy::single_match_else",
"-Wclippy::string_add_assign",
"-Wclippy::string_add",
"-Wclippy::string_lit_as_bytes",
"-Wclippy::string_to_string",
"-Wclippy::todo",
"-Wclippy::trait_duplication_in_bounds",
"-Wclippy::unimplemented",
"-Wclippy::unnested_or_patterns",
"-Wclippy::unused_self",
"-Wclippy::useless_transmute",
"-Wclippy::verbose_file_reads",
"-Wclippy::zero_sized_map_values",
"-Wfuture_incompatible",
"-Wnonstandard_style",
"-Wrust_2018_idioms",
]
10 changes: 10 additions & 0 deletions resources/empty_bounds.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\ LP format example

Minimize
obj: x + 10 y
Subject To
r01: x + y >= 1
Bounds
Binaries
x y
End
28 changes: 0 additions & 28 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,6 @@
//! - Special Order Sets (SOS)
//!

#![deny(
rust_2018_idioms,
unused_must_use,
clippy::nursery,
clippy::pedantic,
clippy::perf,
clippy::correctness,
clippy::dbg_macro,
clippy::else_if_without_else,
clippy::empty_drop,
clippy::empty_structs_with_brackets,
clippy::expect_used,
clippy::if_then_some_else_none,
clippy::integer_division,
clippy::multiple_inherent_impl,
clippy::panic,
clippy::print_stderr,
clippy::print_stdout,
clippy::same_name_method,
clippy::string_to_string,
clippy::todo,
clippy::try_err,
clippy::unimplemented,
clippy::unnecessary_self_imports,
clippy::unreachable,
clippy::unwrap_used,
clippy::wildcard_enum_match_arm
)]
#![allow(clippy::module_name_repetitions)]

use pest_derive::Parser;
Expand Down
4 changes: 2 additions & 2 deletions src/lp_file_format.pest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// https://www.ibm.com/docs/en/icos/22.1.1?topic=cplex-lp-file-format-algebraic-representation
// https://www.fico.com/fico-xpress-optimization/docs/dms2020-03/solver/optimizer/HTML/chapter10_sec_section102.html
// https://www.gurobi.com/documentation/current/refman/lp_format.html
//
//

// Common
WHITESPACE = _{ " " }
Expand Down Expand Up @@ -108,7 +108,7 @@ UPPER_BOUND = { VARIABLE ~ LTE ~ FLOAT }
BOUND = _{
NEWLINE ~ (FREE_VARIABLE | BOUNDED | UPPER_BOUND | LOWER_BOUND | LOWER_BOUND_REV)
}
BOUNDS = { NEWLINE* ~ BOUND_SECTION ~ BOUND+ }
BOUNDS = { NEWLINE* ~ BOUND_SECTION ~ (BOUND+)? }

// Integers
// A list of variable names of integer variables. Unless otherwise specified in the
Expand Down
1 change: 1 addition & 0 deletions tests/test_from_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ generate_test!(semi_continuous, "semi_continuous.lp", Minimize, 2, 2, 7);
generate_test!(sos, "sos.lp", Maximize, 1, 6, 8);
generate_test!(test, "test.lp", Maximize, 1, 4, 12);
generate_test!(test2, "test2.lp", Maximize, 1, 7, 139);
generate_test!(empty_bounds, "empty_bounds.lp", Minimize, 1, 1, 2);

#[test]
#[ignore = "fit2d.mps takes > 60 seconds"]
Expand Down
Loading