Hi, the error is exactly what the traceback says. You need to add spaces.
Old code:

for b in range(1,3):
    #create constraints
m.addConstr(quicksum(x[b,j,t] <=1 for j in J for t in range(r[b],(d[b]-p[b]+
1))),name="block_allocation")    #eqution 2 

Possible new code:

for b in range(1,3):
    #create constraints
    m.addConstr(quicksum(x[b,j,t] <=1 for j in J for t in range(r[b],(d[b]-p
[b]+1))),name="block_allocation")    #eqution 2 

That is if you was the m.addConstr line to run three times.










On Monday, May 1, 2017 at 7:09:14 PM UTC+1, Dina sheweita wrote:
>
> Dears,
>
> I am a postgraduate student and a new user to spyder software too.
>
> I am using this program by python language programming and i pass a long 
> way to learn python and spyder to able to insert my code.
>
> But I faced some errors and I tried to solve it and i succeed but some of 
> them I tried but I don't know what's the problem.
>
> So, I am glad to have this huge community to ask respected experts like 
> you and I wish to support me to solve this issue since I don't have any 
> guide know this software in my college
>
> the error in the equation #2
>
> *for b in range(1,3):*
> *    #create constraints*
> *m.addConstr(quicksum(x[b,j,t] <=1 for j in J for t in 
> range(r[b],(d[b]-p[b]+1))),name="block_allocation")    #eqution 2 *
>
> *the error that showed me up is *
>
> *>>> runfile('C:/Users/Ahmed/AppData/Roaming/Microsoft/Windows/Network 
> Shortcuts/operating_roomintegrated.py', 
> wdir='C:/Users/Ahmed/AppData/Roaming/Microsoft/Windows/Network Shortcuts')*
>
> *Traceback (most recent call last):*
> *  File "<stdin>", line 1, in <module>*
> *  File 
> "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py",
>  
> line 866, in runfile*
> *    execfile(filename, namespace)*
> *  File 
> "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py",
>  
> line 87, in execfile*
> *    exec(compile(scripttext, filename, 'exec'), glob, loc)*
> *  File "C:/Users/Ahmed/AppData/Roaming/Microsoft/Windows/Network 
> Shortcuts/operating_roomintegrated.py", line 31*
> *    m.addConstr(quicksum(x[b,j,t] <=1 for j in J for t in 
> range(r[b],(d[b]-p[b]+1))),name="block_allocation")    #eqution 2 *
> *    ^*
> *IndentationError: expected an indented block*
> *>>> *
>
> this my code:
>
> # -*- coding: utf-8 -*-
> """
> Created on Sun Apr 02 19:36:07 2017
>
> @author: Ahmed
> """
>
> from gurobipy import*
> try:
>     m = Model('operating_room')
>     #Data
>     b= [1,2,3]
>     n= [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]
>     j= [1,2,3,4,5,6,7,8,9,10,11,12,13]
>     
> t=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]
>     W=0.5
>     p[b]= 15
>     h[b]= [1,2,3]
>     m.update()
>     #create variables
>     X[j] =m.addVar(vtype=GRB.BINARY, name="X[j]")
>     Y[n] =m.addVar(vtype=GRB.BINARY, name="Y[n]")
>     x[b,j,t] = m.addVar(vtype=GRB.BINARY,name="x[b,j,t]") 
>     y[n,b] = m.addVar(vtype=GRB.BINARY,name="y[n,b]")
>     m.update()
>     #set objective
>     m.setObjective(quicksum(X[j] for j in J )+ W*(quicksum(Y[n] for n in 
> N)),GRB.MINIMIZE)  #eqution 1
>     
>    * for b in range(1,3):*
> *    #create constraints*
> *    m.addConstr(quicksum(x[b,j,t] <=1 for j in J for t in 
> range(r[b],(d[b]-p[b]+1))),name="block_allocation")    #eqution 2 *
>     #equation 3
>     for b in range(1,b):
>           for j in J:
>               for t in T:
>     m.addConstr(x[b,j,t] <= X[j] ,name="allocation_to_open_OR")
>     #equation 4
>     for j in J:
>         for t in T:
>     m.addConstr(quicksum(x[b,j,l]<=1 for b in range(1:B) for l in 
> range(t-p[b]+1:t)),name="overlaping_blocks")        
>     #equation 5
>     for b in range(1:B):
>     m.addConstr(quicksum(y[n,b]=h[b],for n in 
> N),name="surgical_nurse_demand")    
>     #equation 6
>     for n in N:
>         for b in range(1:B):
>     m.addConstr(y[n,b]<=Y[n],name="used_surgical_nurses")  
>     #equation 7
>     for b,b1 in range(1:B):
>         for n in N:
>             for t in T:
>     m.addConstr(quicksum(x[b,j,l],for j in J for l in range(t-p[b]+1:t)) + 
> quicksum(x[b1,j,l] <= (3-y[n,b]-y[n,b1]),for j in J
>     for l in range(t-p[b1]+1:t)),name="link to scheduling")  
>     #equation 8   
>     for b in range(1:B):
>         for j in J:
>             for t in T:
>     m.addConstr(x[b,j,t] in {0,1},name="integerity_1")          
>     #equation 9
>     for j in J:
>     m.addConstr(X[j] in {0,1},name="integerity_2")                   
>     #equation 10
>     for b in range(1:B):
>         for n in N:
>     m.addConstr(y[n,b] in {0,1},name="integerity_3")            
>     #equation 11     
>     for n in N:
>     m.addConstr(Y[n] in {0,1},name="integerity_4")                   
>     #equation 12
>     for n in N:
>         for b,b1 in range(1:B):
>             for o[b]!= o[b1]:
>     
> m.addConstr(y[n,b]+y[n,b1]<=1,name="assignment_of_nurses_in_different_OR")
>     #equation 13           
>     
> m.addConstr(max(s[b],s[b1])<min(s[b]+p[b],s[b1]+p[b1]),name="prevent_overlapping_in_diff_OR")
>     m.optimize()
>
>
>     
>
>
>
>             
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>             
>             
>             
>             
>             
>             
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to