Skip to content

Commit

Permalink
feat: Restricoes
Browse files Browse the repository at this point in the history
  • Loading branch information
guesant committed Mar 27, 2024
1 parent c08ab80 commit facbbad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
14 changes: 1 addition & 13 deletions projeto-gerar-horario/GerarHorario/Gerador/Gerador.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,7 @@ public static GerarHorarioContext PrepararModelComRestricoes(GerarHorarioOptions
// ==========================================================================================================

// RESTRIÇÃO: Diário: quantidade máxima na semana

foreach (var turma in options.Turmas)
{
foreach (var diario in turma.DiariosDaTurma)
{
var propostasDoDiario = from propostaAula in contexto.TodasAsPropostasDeAula
where
propostaAula.DiarioId == diario.Id
select propostaAula.ModelBoolVar;

contexto.Model.Add(LinearExpr.Sum(propostasDoDiario) <= diario.QuantidadeMaximaSemana);
}
}
Restricoes.AplicarLimiteDiarioSemana(contexto);

// ==========================================================================================================

Expand Down
31 changes: 31 additions & 0 deletions projeto-gerar-horario/GerarHorario/Gerador/Restricoes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@





using Google.OrTools.Sat;
using Sisgea.GerarHorario.Core.Dtos.Configuracoes;

namespace Sisgea.GerarHorario.Core;

public class Restricoes
{
public static void AplicarLimiteDiarioSemana(
GerarHorarioContext contexto
)
{
foreach (var turma in contexto.Options.Turmas)
{
foreach (var diario in turma.DiariosDaTurma)
{
var propostasDoDiario = from propostaAula in contexto.TodasAsPropostasDeAula
where
propostaAula.DiarioId == diario.Id
select propostaAula.ModelBoolVar;

contexto.Model.Add(LinearExpr.Sum(propostasDoDiario) <= diario.QuantidadeMaximaSemana);
}
}

}
}

0 comments on commit facbbad

Please sign in to comment.