~starkingdoms/starkingdoms

3e5cd413bff9de543471151c332b51e657924672 — core 23 days ago 9f1442f
chore: additional debug logging
1 files changed, 8 insertions(+), 5 deletions(-)

M crates/unified/src/client/ship/thrusters.rs
M crates/unified/src/client/ship/thrusters.rs => crates/unified/src/client/ship/thrusters.rs +8 -5
@@ 125,7 125,6 @@ fn solve_thrust(

    for part in &all_parts {
        let Ok(part_thrusters) = parts.get(*part) else {
            warn!("issue while solving for thrust: part {:?} has no thrusters? skipping...", *part);
            continue;
        };
        for thruster_id in &**part_thrusters {


@@ 154,11 153,15 @@ fn solve_thrust(
    // calculate thrust and torque values
    debug!("found {} thrusters, computing coefficients", all_thrusters.len());

    for thruster in &all_thrusters {
        trace!("thruster on ship: {:?}", thruster);
    }

    let coefficients = all_thrusters.iter()
        .map(|u| target_unit_vector.dot(u.1))
        .collect::<Vec<_>>();

    debug!("preparing model");
    trace!("preparing model");
    let mut problem = Problem::new(OptimizationDirection::Maximize);

    // add variables to problem


@@ 166,7 169,7 @@ fn solve_thrust(
        .map(|u| problem.add_binary_var(*u as f64))
        .collect::<Vec<_>>();

    debug!("prepared {} variables; solving", variables.len());
    trace!("prepared {} variables; solving", variables.len());

    let ssolution = match problem.solve() {
        Ok(soln) => soln,


@@ 200,13 203,13 @@ fn solve_thrust(
    };

    for thruster in all_thrusters.iter().enumerate() {
        debug!("solution: thruster #{} ({:?}): {}", thruster.0, thruster.1.0, ssolution.var_value_rounded(variables[thruster.0]));
        trace!("solution: thruster #{} ({:?}): {}", thruster.0, thruster.1.0, ssolution.var_value_rounded(variables[thruster.0]));
        if ssolution.var_value_rounded(variables[thruster.0]) == 1.0 {
            new_soln.thrusters_on.insert(*thruster.1.0);
        }
    }

    debug!("found thrust solution in {}ms", start.elapsed().as_millis());
    debug!("found thrust solution in {:?}", start.elapsed());
    *solution = new_soln;
    return;
}
\ No newline at end of file