@@ -514,3 +514,102 @@ function solve_zero_one_with_bounds_3(model::MOI.ModelLike, config::TestConfig)
514514 end
515515end
516516unittests[" solve_zero_one_with_bounds_3" ] = solve_zero_one_with_bounds_3
517+
518+ function solve_constrs_with_inf_bounds (model:: MOI.ModelLike , config:: TestConfig )
519+ MOI. empty! (model)
520+ x = MOI. add_variable (model)
521+ y = MOI. add_variable (model)
522+ objective_function = MOI. ScalarAffineFunction (
523+ [MOI. ScalarAffineTerm (1.0 , x), MOI. ScalarAffineTerm (- 1.0 , y)],
524+ 0.0
525+ )
526+ MOI. set (
527+ model,
528+ MOI. ObjectiveFunction {typeof(objective_function)} (),
529+ objective_function,
530+ )
531+ MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
532+
533+ c1 = MOI. add_constraint (
534+ model,
535+ MOI. SingleVariable (x),
536+ MOI. LessThan {Float64} (1.0 )
537+ )
538+ c2 = MOI. add_constraint (
539+ model,
540+ MOI. SingleVariable (x),
541+ MOI. GreaterThan {Float64} (- Inf )
542+ )
543+ c3 = MOI. add_constraint (
544+ model,
545+ MOI. SingleVariable (y),
546+ MOI. LessThan {Float64} (Inf )
547+ )
548+ c4 = MOI. add_constraint (
549+ model,
550+ MOI. SingleVariable (y),
551+ MOI. GreaterThan {Float64} (- 1.0 )
552+ )
553+
554+ @test MOI. is_valid (model, c2)
555+ @test MOI. is_valid (model, c3)
556+
557+ return test_model_solution (
558+ model,
559+ config;
560+ objective_value = 2.0 ,
561+ variable_primal = [(x, 1.0 ), (y, - 1.0 )],
562+ )
563+ end
564+ unittests[" solve_constrs_with_inf_bounds" ] = solve_constrs_with_inf_bounds
565+
566+ function solve_one_sided_intervals (model:: MOI.ModelLike , config:: TestConfig )
567+ MOI. empty! (model)
568+ MOIU. loadfromstring! (
569+ model,
570+ """
571+ variables: x, y, z
572+ maxobjective: x + -1y + z
573+ c1: x in Interval(-Inf, 1.0)
574+ c2: y in Interval(-1.0, Inf)
575+ c3: z in Interval(-Inf, Inf)
576+ c4: 1z <= 1.0
577+ """ ,
578+ )
579+
580+ x = MOI. get (model, MOI. VariableIndex, " x" )
581+ y = MOI. get (model, MOI. VariableIndex, " y" )
582+ z = MOI. get (model, MOI. VariableIndex, " z" )
583+
584+ c1 = MOI. get (
585+ model,
586+ MOI. ConstraintIndex{MOI. SingleVariable, MOI. Interval{Float64}},
587+ " c1"
588+ )
589+ c2 = MOI. get (
590+ model,
591+ MOI. ConstraintIndex{MOI. SingleVariable, MOI. Interval{Float64}},
592+ " c2"
593+ )
594+ c3 = MOI. get (
595+ model,
596+ MOI. ConstraintIndex{MOI. SingleVariable, MOI. Interval{Float64}},
597+ " c3"
598+ )
599+
600+ @test MOI. get (model, MOI. ConstraintIndex, " c1" ) == c1
601+ @test MOI. get (model, MOI. ConstraintIndex, " c2" ) == c2
602+ @test MOI. get (model, MOI. ConstraintIndex, " c3" ) == c3
603+
604+ @test MOI. is_valid (model, c1)
605+ @test MOI. is_valid (model, c2)
606+ @test MOI. is_valid (model, c3)
607+
608+ return test_model_solution (
609+ model,
610+ config;
611+ objective_value = 3.0 ,
612+ variable_primal = [(x, 1.0 ), (y, - 1.0 ), (z, 1.0 )],
613+ )
614+ end
615+ unittests[" solve_one_sided_intervals" ] = solve_one_sided_intervals
0 commit comments