09.05.2013 Views

Algoritmos Heurísticos de Cobertura de Arcos

Algoritmos Heurísticos de Cobertura de Arcos

Algoritmos Heurísticos de Cobertura de Arcos

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

,InicioRota,' ',InicioRotaCoordI,' ',InicioRotaCoordJ,' '<br />

,-MenosInf, ' 1');<br />

Caractere:=' ';<br />

If Not EoF(Re<strong>de</strong>) Then<br />

ReadLn(Re<strong>de</strong>,Caractere);<br />

If Caractere'*'<br />

Then<br />

begin<br />

CloseFile(Re<strong>de</strong>);<br />

CloseFile(Re<strong>de</strong>Temp);<br />

Exit;<br />

end<br />

Else<br />

WriteLn(Re<strong>de</strong>Temp,'* Conversões Permitidas, ou Penalizadas');<br />

While Not EoF(Re<strong>de</strong>) Do<br />

Begin // Inserindo as conversoes permitidas, com respeito ao arco artificial<br />

NoRepetidoi:=0;<br />

NoRepetidoj:=0;<br />

ReadLn(Re<strong>de</strong>, N1,N2,N3,Custo);<br />

WriteLn(Re<strong>de</strong>Temp,N1,' ',N2,' ',N3,' ',Custo);<br />

If (N3=FimRota) and (N2NoRepetidoi) Then<br />

WriteLn(Re<strong>de</strong>Temp,N2,' ',N3,' ',InicioRota,' 0');<br />

NoRepetidoi:=N2;<br />

If (N1=InicioRota) and (N2NoRepetidoj) Then<br />

WriteLn(Re<strong>de</strong>Temp,FimRota,' ',N1,' ',N2,' 0');<br />

NoRepetidoj:=N2;<br />

end;<br />

Close(Re<strong>de</strong>);<br />

CloseFile(Re<strong>de</strong>Temp);<br />

end;<br />

Function CustoConversao(No1, No2, No3: Integer):Integer;<br />

var caracter:String[1];<br />

NaoAchou:Boolean;<br />

N1,N2,N3,Custo:Integer;<br />

begin<br />

custo:=0;<br />

ArqErrado:=false;<br />

If Form1.CheckBox3.Checked=false Then Exit;<br />

//Assign(Re<strong>de</strong>,ArqNome);<br />

Assign(Re<strong>de</strong>,ArqTemp);<br />

Reset(Re<strong>de</strong>);<br />

Caracter:='';<br />

While (Caracter'*') And (Not EoF(Re<strong>de</strong>)) Do<br />

ReadLn(Re<strong>de</strong>,Caracter);<br />

If Caracter'*' Then<br />

begin<br />

Application.messagebox('Verifique se o arquivo contém a lista das conversões viáveis'<br />

,'Formato do Arquivo Incorreto',MB_OK);<br />

Close(Re<strong>de</strong>);<br />

ArqErrado:=true;<br />

Exit;<br />

end;<br />

NaoAchou:=true;<br />

While (Not EoF(Re<strong>de</strong>)) And (NaoAchou) Do<br />

Begin<br />

ReadLn(Re<strong>de</strong>, N1,N2,N3,Custo);<br />

If N1=No1 Then<br />

If N2=No2 Then<br />

If N3=No3 Then<br />

NaoAchou:=false;<br />

end;<br />

If NaoAchou Then Custo:=Penalida<strong>de</strong>;<br />

Result:=Custo;<br />

Close(Re<strong>de</strong>);<br />

155

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!