@@ -412,119 +412,142 @@ end
412
412
function init_constraints! (com:: CS.CoM ; constraints= com. constraints)
413
413
feasible = true
414
414
for constraint in constraints
415
- c_type = typeof (constraint)
416
- c_fct_type = typeof (constraint. std. fct)
417
- c_set_type = typeof (constraint. std. set)
418
- if hasmethod (init_constraint!, (CS. CoM, c_type, c_fct_type, c_set_type))
415
+ if constraint. std. impl. init
419
416
feasible = init_constraint! (com, constraint, constraint. std. fct, constraint. std. set)
420
417
! feasible && break
421
418
end
422
- constraint. std. impl . init = true
419
+ constraint. std. is_initialized = true
423
420
end
424
421
return feasible
425
422
end
426
423
424
+ """
425
+ set_impl_functions!(com, constraint::Constraint)
426
+
427
+ Set std.impl.[] for each constraint
428
+ """
429
+ function set_impl_functions! (com, constraint:: Constraint )
430
+ if com. sense != MOI. FEASIBILITY_SENSE
431
+ set_impl_update_best_bound! (constraint)
432
+ end
433
+ set_impl_init! (constraint)
434
+ set_impl_finished_pruning! (constraint)
435
+ set_impl_restore_pruning! (constraint)
436
+ set_impl_reverse_pruning! (constraint)
437
+ end
438
+
439
+ """
440
+ set_impl_functions!(com::CS.CoM)
441
+
442
+ Set std.impl.[] for each constraint
443
+ """
444
+ function set_impl_functions! (com:: CS.CoM ; constraints= com. constraints)
445
+ for constraint in constraints
446
+ set_impl_functions! (com, constraint)
447
+ end
448
+ end
449
+
427
450
"""
428
- set_update_best_bound!(com::CS.CoM)
429
- Sets `update_best_bound` in each constraint if we have an objective function and:
430
- - the constraint type has a function `update_best_bound_constraint!`
451
+ set_impl_init!(constraint::Constraint)
452
+ Sets `std.impl.init` if the constraint type has a `init_constraint!` method
431
453
"""
432
- function set_update_best_bound! (com:: CS.CoM )
433
- if com. sense == MOI. FEASIBILITY_SENSE
434
- return
435
- end
436
- objective_type = typeof (com. objective)
437
- for ci = 1 : length (com. constraints)
438
- constraint = com. constraints[ci]
439
- c_type = typeof (constraint)
440
- c_fct_type = typeof (constraint. std. fct)
441
- c_set_type = typeof (constraint. std. set)
442
- if hasmethod (
443
- update_best_bound_constraint!,
444
- (CS. CoM, c_type, c_fct_type, c_set_type, Int, Int, Int),
445
- )
446
- constraint. std. impl. update_best_bound = true
447
- else # just to be sure => set it to false otherwise
448
- constraint. std. impl. update_best_bound = false
449
- end
450
- end
454
+ function set_impl_init! (constraint:: Constraint )
455
+ c_type = typeof (constraint)
456
+ c_fct_type = typeof (constraint. std. fct)
457
+ c_set_type = typeof (constraint. std. set)
458
+ if hasmethod (init_constraint!, (CS. CoM, c_type, c_fct_type, c_set_type))
459
+ constraint. std. impl. init = true
460
+ end
451
461
end
452
462
453
463
"""
454
- set_reverse_pruning!(com::CS.CoM )
455
- Sets `std.impl.single_reverse_pruning` and `std.impl.reverse_pruning` in each constraint
456
- if `single_reverse_pruning_constraint!`, `reverse_pruning_constraint!` are implemented for the constraint.
464
+ set_impl_update_best_bound!(constraint::Constraint )
465
+
466
+ Sets `update_best_bound` if the constraint type has a `update_best_bound_constraint!` method
457
467
"""
458
- function set_reverse_pruning! (com:: CS.CoM )
459
- for ci = 1 : length (com. constraints)
460
- constraint = com. constraints[ci]
461
- c_type = typeof (constraint)
462
- c_fct_type = typeof (constraint. std. fct)
463
- c_set_type = typeof (constraint. std. set)
464
- if hasmethod (
465
- single_reverse_pruning_constraint!,
466
- (CS. CoM, c_type, c_fct_type, c_set_type, Int, Vector{Tuple{Symbol,Int,Int,Int}}),
467
- )
468
- constraint. std. impl. single_reverse_pruning = true
469
- else # just to be sure => set it to false otherwise
470
- constraint. std. impl. single_reverse_pruning = false
471
- end
472
-
473
- if hasmethod (
474
- reverse_pruning_constraint!,
475
- (CS. CoM, c_type, c_fct_type, c_set_type, Int),
476
- )
477
- constraint. std. impl. reverse_pruning = true
478
- else # just to be sure => set it to false otherwise
479
- constraint. std. impl. reverse_pruning = false
480
- end
468
+ function set_impl_update_best_bound! (constraint:: Constraint )
469
+ c_type = typeof (constraint)
470
+ c_fct_type = typeof (constraint. std. fct)
471
+ c_set_type = typeof (constraint. std. set)
472
+ if hasmethod (
473
+ update_best_bound_constraint!,
474
+ (CS. CoM, c_type, c_fct_type, c_set_type, Int, Int, Int),
475
+ )
476
+ constraint. std. impl. update_best_bound = true
477
+ else # just to be sure => set it to false otherwise
478
+ constraint. std. impl. update_best_bound = false
481
479
end
482
480
end
483
481
484
482
"""
485
- set_finished_pruning!(com::CS.CoM )
486
- Sets `std.impl.finished_pruning` in each constraint
487
- if `finished_pruning_constraint!` is implemented for the constraint.
483
+ set_impl_reverse_pruning!(constraint::Constraint )
484
+ Sets `std.impl.single_reverse_pruning` and `std.impl.reverse_pruning`
485
+ if `single_reverse_pruning_constraint!`, `reverse_pruning_constraint!` are implemented for ` constraint` .
488
486
"""
489
- function set_finished_pruning! (com:: CS.CoM )
490
- for ci = 1 : length (com. constraints)
491
- constraint = com. constraints[ci]
492
- c_type = typeof (constraint)
493
- c_fct_type = typeof (constraint. std. fct)
494
- c_set_type = typeof (constraint. std. set)
495
- if hasmethod (
496
- finished_pruning_constraint!,
497
- (CS. CoM, c_type, c_fct_type, c_set_type)
498
- )
499
- constraint. std. impl. finished_pruning = true
500
- else # just to be sure => set it to false otherwise
501
- constraint. std. impl. finished_pruning = false
502
- end
487
+ function set_impl_reverse_pruning! (constraint:: Constraint )
488
+ c_type = typeof (constraint)
489
+ c_fct_type = typeof (constraint. std. fct)
490
+ c_set_type = typeof (constraint. std. set)
491
+ if hasmethod (
492
+ single_reverse_pruning_constraint!,
493
+ (CS. CoM, c_type, c_fct_type, c_set_type, CS. Variable, Int),
494
+ )
495
+ constraint. std. impl. single_reverse_pruning = true
496
+ else # just to be sure => set it to false otherwise
497
+ constraint. std. impl. single_reverse_pruning = false
498
+ end
499
+
500
+ if hasmethod (
501
+ reverse_pruning_constraint!,
502
+ (CS. CoM, c_type, c_fct_type, c_set_type, Int),
503
+ )
504
+ constraint. std. impl. reverse_pruning = true
505
+ else # just to be sure => set it to false otherwise
506
+ constraint. std. impl. reverse_pruning = false
503
507
end
504
508
end
505
509
506
510
"""
507
- set_restore_pruning!(com::CS.CoM)
508
- Sets `std.impl.restore_pruning` in each constraint
509
- if `restore_pruning_constraint!` is implemented for the constraint.
511
+ set_impl_finished_pruning!(constraint::Constraint)
512
+ Sets `std.impl.finished_pruning` if `finished_pruning_constraint!` is implemented for `constraint`.
510
513
"""
511
- function set_restore_pruning! (com:: CS.CoM )
512
- for ci = 1 : length (com. constraints)
513
- constraint = com. constraints[ci]
514
- c_type = typeof (constraint)
515
- c_fct_type = typeof (constraint. std. fct)
516
- c_set_type = typeof (constraint. std. set)
517
- if hasmethod (
518
- restore_pruning_constraint!,
519
- (CS. CoM, c_type, c_fct_type, c_set_type, Union{Int, Vector{Int}})
520
- )
521
- constraint. std. impl. restore_pruning = true
522
- else # just to be sure => set it to false otherwise
523
- constraint. std. impl. restore_pruning = false
524
- end
525
- end
514
+ function set_impl_finished_pruning! (constraint:: Constraint )
515
+ c_type = typeof (constraint)
516
+ c_fct_type = typeof (constraint. std. fct)
517
+ c_set_type = typeof (constraint. std. set)
518
+ if hasmethod (
519
+ finished_pruning_constraint!,
520
+ (CS. CoM, c_type, c_fct_type, c_set_type)
521
+ )
522
+ constraint. std. impl. finished_pruning = true
523
+ else # just to be sure => set it to false otherwise
524
+ constraint. std. impl. finished_pruning = false
525
+ end
526
+ end
527
+
528
+ """
529
+ set_impl_restore_pruning!(constraint::Constraint)
530
+ Sets `std.impl.restore_pruning` if `restore_pruning_constraint!` is implemented for the `constraint`.
531
+ """
532
+ function set_impl_restore_pruning! (constraint:: Constraint )
533
+ c_type = typeof (constraint)
534
+ c_fct_type = typeof (constraint. std. fct)
535
+ c_set_type = typeof (constraint. std. set)
536
+ if hasmethod (
537
+ restore_pruning_constraint!,
538
+ (CS. CoM, c_type, c_fct_type, c_set_type, Union{Int, Vector{Int}})
539
+ )
540
+ constraint. std. impl. restore_pruning = true
541
+ else # just to be sure => set it to false otherwise
542
+ constraint. std. impl. restore_pruning = false
543
+ end
526
544
end
527
545
546
+ """
547
+ call_finished_pruning!(com)
548
+
549
+ Call `finished_pruning_constraint!` for every constraint which implements that function as saved in `constraint.std.impl.finished_pruning`
550
+ """
528
551
function call_finished_pruning! (com)
529
552
for constraint in com. constraints
530
553
if constraint. std. impl. finished_pruning
@@ -533,6 +556,11 @@ function call_finished_pruning!(com)
533
556
end
534
557
end
535
558
559
+ """
560
+ call_restore_pruning!(com, prune_steps)
561
+
562
+ Call `call_restore_pruning!` for every constraint which implements that function as saved in `constraint.std.impl.restore_pruning`
563
+ """
536
564
function call_restore_pruning! (com, prune_steps)
537
565
for constraint in com. constraints
538
566
if constraint. std. impl. restore_pruning
0 commit comments