mirror of https://codeberg.org/topola/topola.git
feat(autorouter/multilayer_reconfigurator): Add reconfiguration trigger here too
This commit is contained in:
parent
e1774ce6d9
commit
9345d5de8a
|
|
@ -74,24 +74,23 @@ impl MultilayerAutorouteReconfigurator {
|
||||||
preconfiguration,
|
preconfiguration,
|
||||||
options,
|
options,
|
||||||
)?,
|
)?,
|
||||||
reconfiguration_trigger: SmaRateReconfigurationTrigger::new(10, 0.5, 0.1),
|
reconfiguration_trigger: SmaRateReconfigurationTrigger::new(20, 0.5, 0.1),
|
||||||
reconfigurer,
|
reconfigurer,
|
||||||
options,
|
options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reconfigure<M: AccessMesadata>(
|
fn reconfigure(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<M>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
) -> Result<ControlFlow<Option<BoardEdit>, MultilayerReconfiguratorStatus>, AutorouterError>
|
) -> Result<ControlFlow<Option<BoardEdit>, MultilayerReconfiguratorStatus>, AutorouterError>
|
||||||
{
|
{
|
||||||
// Reset the reconfiguration trigger.
|
// Reset the reconfiguration trigger.
|
||||||
self.reconfiguration_trigger = SmaRateReconfigurationTrigger::new(10, 0.5, 0.1);
|
self.reconfiguration_trigger = SmaRateReconfigurationTrigger::new(20, 1.0, 0.1);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let configuration = match self.reconfigurer.next_configuration(autorouter) {
|
let Some(configuration) = self.reconfigurer.next_configuration(autorouter) else {
|
||||||
None => return Ok(ControlFlow::Break(None)),
|
return Ok(ControlFlow::Break(None));
|
||||||
Some(configuration) => configuration,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match self.stepper.reconfigure(autorouter, configuration) {
|
match self.stepper.reconfigure(autorouter, configuration) {
|
||||||
|
|
@ -141,7 +140,7 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, MultilayerReconfi
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.reconfigurer
|
self.reconfigurer
|
||||||
.process_planar_result(autorouter, Err(err.clone()));
|
.process_planar_result(autorouter, Err(err.clone()));
|
||||||
Err(err)
|
self.reconfigure(autorouter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@ use crate::{
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::primitive::PrimitiveShape,
|
geometry::primitive::PrimitiveShape,
|
||||||
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
||||||
stepper::{Abort, EstimateProgress, LinearScale, ReconfiguratorStatus, Reconfigure, Step},
|
stepper::{
|
||||||
|
Abort, EstimateProgress, LinearScale, ReconfiguratorStatus, Reconfigure,
|
||||||
|
SmaRateReconfigurationTrigger, Step,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type PlanarAutorouteReconfiguratorStatus =
|
pub type PlanarAutorouteReconfiguratorStatus =
|
||||||
|
|
@ -32,6 +35,7 @@ pub type PlanarAutorouteReconfiguratorStatus =
|
||||||
|
|
||||||
pub struct PlanarAutorouteReconfigurator {
|
pub struct PlanarAutorouteReconfigurator {
|
||||||
stepper: PlanarAutorouteExecutionStepper,
|
stepper: PlanarAutorouteExecutionStepper,
|
||||||
|
reconfiguration_trigger: SmaRateReconfigurationTrigger,
|
||||||
reconfigurer: PlanarAutorouteReconfigurer,
|
reconfigurer: PlanarAutorouteReconfigurer,
|
||||||
options: PlanarAutorouteOptions,
|
options: PlanarAutorouteOptions,
|
||||||
}
|
}
|
||||||
|
|
@ -61,32 +65,19 @@ impl PlanarAutorouteReconfigurator {
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
stepper: PlanarAutorouteExecutionStepper::new(autorouter, preconfiguration, options)?,
|
stepper: PlanarAutorouteExecutionStepper::new(autorouter, preconfiguration, options)?,
|
||||||
|
reconfiguration_trigger: SmaRateReconfigurationTrigger::new(5, 0.5, 0.1),
|
||||||
// Note: I assume here that the first permutation is the same as the original order.
|
// Note: I assume here that the first permutation is the same as the original order.
|
||||||
reconfigurer,
|
reconfigurer,
|
||||||
options,
|
options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteReconfiguratorStatus>
|
fn reconfigure(
|
||||||
for PlanarAutorouteReconfigurator
|
|
||||||
{
|
|
||||||
type Error = AutorouterError;
|
|
||||||
|
|
||||||
fn step(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<M>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteReconfiguratorStatus>, AutorouterError>
|
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteReconfiguratorStatus>, AutorouterError>
|
||||||
{
|
{
|
||||||
match self.stepper.step(autorouter) {
|
self.reconfiguration_trigger = SmaRateReconfigurationTrigger::new(5, 0.5, 0.1);
|
||||||
Ok(ControlFlow::Break(maybe_edit)) => Ok(ControlFlow::Break(maybe_edit)),
|
|
||||||
Ok(ControlFlow::Continue(status)) => {
|
|
||||||
Ok(ControlFlow::Continue(ReconfiguratorStatus::Running(status)))
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
if !self.options.permutate {
|
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let Some(configuration) = self
|
let Some(configuration) = self
|
||||||
|
|
@ -107,6 +98,36 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteRe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteReconfiguratorStatus>
|
||||||
|
for PlanarAutorouteReconfigurator
|
||||||
|
{
|
||||||
|
type Error = AutorouterError;
|
||||||
|
|
||||||
|
fn step(
|
||||||
|
&mut self,
|
||||||
|
autorouter: &mut Autorouter<M>,
|
||||||
|
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteReconfiguratorStatus>, AutorouterError>
|
||||||
|
{
|
||||||
|
if !self
|
||||||
|
.reconfiguration_trigger
|
||||||
|
.update(*self.estimate_progress().value() as f64)
|
||||||
|
{
|
||||||
|
return self.reconfigure(autorouter);
|
||||||
|
}
|
||||||
|
|
||||||
|
match self.stepper.step(autorouter) {
|
||||||
|
Ok(ControlFlow::Break(maybe_edit)) => Ok(ControlFlow::Break(maybe_edit)),
|
||||||
|
Ok(ControlFlow::Continue(status)) => {
|
||||||
|
Ok(ControlFlow::Continue(ReconfiguratorStatus::Running(status)))
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
if !self.options.permutate {
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
self.reconfigure(autorouter)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use crate::autorouter::{
|
||||||
pub trait MakeNextPlanarAutorouteConfiguration {
|
pub trait MakeNextPlanarAutorouteConfiguration {
|
||||||
fn next_configuration(
|
fn next_configuration(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &Autorouter<impl AccessMesadata>,
|
||||||
stepper: &PlanarAutorouteExecutionStepper,
|
stepper: &PlanarAutorouteExecutionStepper,
|
||||||
) -> Option<PlanarAutorouteConfiguration>;
|
) -> Option<PlanarAutorouteConfiguration>;
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +78,7 @@ impl SccPermutationsPlanarAutorouteReconfigurer {
|
||||||
impl MakeNextPlanarAutorouteConfiguration for SccPermutationsPlanarAutorouteReconfigurer {
|
impl MakeNextPlanarAutorouteConfiguration for SccPermutationsPlanarAutorouteReconfigurer {
|
||||||
fn next_configuration(
|
fn next_configuration(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &Autorouter<impl AccessMesadata>,
|
||||||
_stepper: &PlanarAutorouteExecutionStepper,
|
_stepper: &PlanarAutorouteExecutionStepper,
|
||||||
) -> Option<PlanarAutorouteConfiguration> {
|
) -> Option<PlanarAutorouteConfiguration> {
|
||||||
let scc_permutation = self.sccs_permutations_iter.next()?;
|
let scc_permutation = self.sccs_permutations_iter.next()?;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue