Skip to content

Commit 2c7f70d

Browse files
GiggleLiuclaude
andcommitted
fix: add --bounds flag for CVP creation, consistent with schema
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 150a0df commit 2c7f70d

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

problemreductions-cli/src/cli.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Flags by problem type:
215215
MinimumSetCovering --universe, --sets [--weights]
216216
BicliqueCover --left, --right, --biedges, --k
217217
BMF --matrix (0/1), --rank
218-
CVP --basis, --target-vec
218+
CVP --basis, --target-vec [--bounds]
219219
ILP, CircuitSAT (via reduction only)
220220
221221
Geometry graph variants (use slash notation, e.g., MIS/KingsSubgraph):
@@ -323,6 +323,9 @@ pub struct CreateArgs {
323323
/// Target vector for CVP (comma-separated, e.g., "0.5,0.5")
324324
#[arg(long)]
325325
pub target_vec: Option<String>,
326+
/// Variable bounds for CVP as "lower,upper" (e.g., "-10,10") [default: -10,10]
327+
#[arg(long, allow_hyphen_values = true)]
328+
pub bounds: Option<String>,
326329
}
327330

328331
#[derive(clap::Args)]

problemreductions-cli/src/commands/create.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn all_data_flags_empty(args: &CreateArgs) -> bool {
4444
&& args.rank.is_none()
4545
&& args.basis.is_none()
4646
&& args.target_vec.is_none()
47+
&& args.bounds.is_none()
4748
}
4849

4950
fn type_format_hint(type_name: &str, graph_type: Option<&str>) -> &'static str {
@@ -425,7 +426,17 @@ pub fn create(args: &CreateArgs, out: &OutputConfig) -> Result<()> {
425426
.collect::<Result<Vec<_>>>()?;
426427
let target: Vec<f64> = util::parse_comma_list(target_str)?;
427428
let n = basis.len();
428-
let bounds = vec![problemreductions::models::algebraic::VarBounds::bounded(-10, 10); n];
429+
let (lo, hi) = match args.bounds.as_deref() {
430+
Some(s) => {
431+
let parts: Vec<i64> = util::parse_comma_list(s)?;
432+
if parts.len() != 2 {
433+
bail!("--bounds expects \"lower,upper\" (e.g., \"-10,10\")");
434+
}
435+
(parts[0], parts[1])
436+
}
437+
None => (-10, 10),
438+
};
439+
let bounds = vec![problemreductions::models::algebraic::VarBounds::bounded(lo, hi); n];
429440
(
430441
ser(ClosestVectorProblem::new(basis, target, bounds))?,
431442
resolved_variant.clone(),

0 commit comments

Comments
 (0)