Modulo operation on a NewIntVar

419 views
Skip to first unread message

Sercan Oruç

unread,
Nov 12, 2018, 6:01:13 AM11/12/18
to or-tools...@googlegroups.com
Hello,

Is there a way to perform modulo operation on a NewIntVar? 

"model.Add(start1 % 7 == 5)" line in the below script does not work. 

All the best,
Sercan


Example Script: 
from ortools.sat.python import cp_model

def main():

    model = cp_model.CpModel()
       
    start1 = model.NewIntVar(0, 50, 'start1')
    duration1 = 10
    end1 = model.NewIntVar(0, 50, 'end1')

    model.Add(start1 + duration1 <= end1)
    
    model.Add(start1 % 7 == 5) 

    model.Minimize(end1)

    solver = cp_model.CpSolver()
    status = solver.Solve(model)
    
    print(solver.StatusName(status))    
    print(solver.ObjectiveValue())
    
    if status == cp_model.FEASIBLE or status == cp_model.OPTIMAL:
        v_start1 = solver.Value(start1)
        v_end1 = solver.Value(end1)
        print('Task 1 starts at %i and ends at %i with duration %i' 
              %(v_start1,v_end1,duration1))
        
        
if __name__ == '__main__':
  main()

Laurent Perron

unread,
Nov 12, 2018, 6:51:34 AM11/12/18
to or-tools...@googlegroups.com
model.AddModuloEquality(start1, 7, 5)
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages