Skip to content
The Chat Archive
Amazon Novaamazon-nova-experimental-chat-05-14· Amazon LMArena Human Preference 140K

Do you see a problem here? I get exact new results for both runs. MU = 0.5 # Coefficient…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmistral-small-3.1-24b-instruct-2503’s answer.
  1. User

    Do you see a problem here? I get exact new results for both runs.

    MU = 0.5 # Coefficient of friction T = 1.5 # Total time T_UB = 2.0 # Upper bound on total time N_knots = 25 # Number of knot points per segment M = 74 # Mass of the pendulum (kg) L = 1.74 # Length of the pendulum (m) lleg = Link(m=0.093 * M, l=0.246 * L) # Lower leg link uleg = Link(m=0.200 * M, l=0.245 * L) # Upper leg link torso = Link(m=0.678 * M, l=0.47 * L) # Torso link

    lleg = Link(m=1, l=1) # Link 1

    uleg = Link(m=1, l=1) # Link 2

    torso = Link(m=1, l=1) # Link 3

    SEAT_POS = (-0.4, 0.4) # Seat position FOOT_X_LIMS = (-0.05, 0.2) # Foot x limits R_weights_init = (1, 1, 1) # Control weights R_weights = (1, 3, 1)

    U_UB = (None,) * 3 # Upper bound on control inputs U_LB = (None,) * 3 # Lower bound on control inputs

    Define the system

    sts = STS(link1=lleg, link2=uleg, link3=torso, mu=MU, seat_pos=SEAT_POS, foot_x_lims=FOOT_X_LIMS) sts_optimizer = STSTrajectoryOptimizer(sts, control_weights=R_weights_init, )

    x0 = (None, None, -0.01, 0, 0, 0) # Initial state xf = (0, 0, 0, 0, 0, 0)

    j1, j2 = solve_ik_optimization(*SEAT_POS, lleg.l, uleg.l)

    Adjust the joint angles to match STS convention

    j2 = j1 + j2 - np.pi/2 j1 = j1 - np.pi/2 print(j1, j2) sit_mode_initial_guess_x0 = np.array([j1, j2, -0.01, 0, 0, 0]).reshape(-1, 1) sit_mode_initial_guess_xf = np.array([j1, j2, -np.pi/6, 0, 0, -0.1]).reshape(-1, 1) sit_mode_initial_guess = np.hstack((sit_mode_initial_guess_x0, sit_mode_initial_guess_xf))

    mode_sit = Mode( name='sit', dynamics_fn=sts.sit_dynamics_fn, n_x=6, n_u=3, constraints_fns=[ sts_optimizer.seat_contact_no_slip_constraint_fn, sts_optimizer.sit_path_constraint_fn, ], initial_x_guess=sit_mode_initial_guess, u_lb=U_LB, u_ub=U_UB, )

    mode_stand = Mode( name='stand', dynamics_fn=sts.stand_dynamics_fn, n_x=6, n_u=3, constraints_fns=[
    # sts_optimizer.COP_constraint_fn, sts_optimizer.knee_joint_constraint_fn, ], u_lb=U_LB, u_ub=U_UB, )

    transition_sit_stand = Transition( guard_fn=lambda x, u: sts.sit_contact_force_fn(x, u)[1], # y component of the contact force reset_map_fn=sts_optimizer.sit_stand_map_fn, )

    hybrid_params = HybridSystemParams( mode_sequence=[mode_sit, mode_stand], transitions=[transition_sit_stand], x0=x0, # Initial state xf=xf, # Final state # T = T, # Total time T_ub = T_UB, # Upper bound on total time min_time_step = 1E-6, num_knot_points_per_segment = N_knots, # Number of knot points per segment )

    hybrid_optimizer = HybridTrajectoryOptimizer( params=hybrid_params, cost_fn=sts_optimizer.cost_function, global_constraints_fns=[sts_optimizer.base_contact_no_slip_global_constraint_fn, sts_optimizer.COP_global_constraint_fn, sts_optimizer.equal_time_segment_global_constraint_fn, sts_optimizer.control_effort_vanishes_global_constraint_fn, ], )

    Solve the optimization problem

    solver_name = 'ipopt' solver_options = { 'ipopt.print_level': 5, 'ipopt.max_iter': 3000, 'ipopt.fixed_variable_treatment': 'relax_bounds', 'ipopt.tol': 1E-3, }

    solution = hybrid_optimizer.solve(solver_name=solver_name, opts=solver_options)

    Now use the solution to warm start the simulation

    DIRTY JOB

    sts_optimizer.R = ca.diag(R_weights) # Update the control weights

    hybrid_optimizer._setup_objective() # Re-setup the objective function with the new weights

    solution = hybrid_optimizer.solve(solver_name, solver_options, warm_start=True)

    SEAT_POS_NEW = (None, 0.2) # New seat position

    Update the initial guess for the sit mode

    mode_sit.initial_x_guess = solution['states'][0] mode_stand.initial_x_guess = solution['states'][1] sts_new = STS(link1=lleg, link2=uleg, link3=torso, mu=MU, seat_pos=SEAT_POS_NEW, foot_x_lims=FOOT_X_LIMS) sts_optimizer_new = STSTrajectoryOptimizer(sts_new, control_weights=R_weights_init, ) hybrid_params_new = HybridSystemParams( mode_sequence=[mode_sit, mode_stand], transitions=[transition_sit_stand], x0=x0, # Initial state xf=xf, # Final state # T = T, # Total time T_ub=T_UB, # Upper bound on total time min_time_step=1E-6, num_knot_points_per_segment=N_knots, # Number of knot points per segment )

    Recreate the hybrid optimizer with the new system

    hybrid_optimizer_new = HybridTrajectoryOptimizer( params=hybrid_params_new, cost_fn=sts_optimizer_new.cost_function, global_constraints_fns=[sts_optimizer_new.base_contact_no_slip_global_constraint_fn, sts_optimizer_new.COP_global_constraint_fn, sts_optimizer_new.equal_time_segment_global_constraint_fn, sts_optimizer_new.control_effort_vanishes_global_constraint_fn, ], )

    Solve the optimization problem again with the new system

    solution = hybrid_optimizer_new.solve(solver_name=solver_name, opts=solver_options)

    End of dirty job

  2. Assistant

    Let's break down the code and identify potential issues that could lead to getting exact new results for both runs, which seems unexpected given that you are changing the SEAT_POS between the two runs.

    Potential Issues and Suggestions

    1. Seat Position Update:

      • Issue: SEAT_POS_NEW = (None, 0.2) might not be correctly updating the seat position. The first element is None, which could be causing an issue.
      • Suggestion: Ensure that SEAT_POS_NEW is a valid tuple with two numeric values. For example SEAT_POS_NEW = (-0.4, 0.2)
      SEAT_POS_NEW = (-0.4, 0.2)  # New seat position
      
    2. Initial Guess Update:

      • Issue: You are updating the initial guess for mode_sit and mode_stand using the solution from the previous optimisation. However you are not updating the initial guess for the new seat position which might lead to the same result.
      • Suggestion: Update the initial joint angles j1 and j2 for the new seat position.
      # Update joint angles for the new seat position
      j1_new, j2_new = solve_ik_optimization(*SEAT_POS_NEW, lleg.l, uleg.l)
      # Adjust the joint angles to match STS convention
      j2_new = j1_new + j2_new - np.pi/2
      j1_new = j1_new - np.pi/2
      print(j1_new, j2_new)
      sit_mode_initial_guess_x0_new = np.array([j1_new, j2_new, -0.01, 0, 0, 0]).reshape(-1, 1) 
      sit_mode_initial_guess_xf_new = np.array([j1_new, j2_new, -np.pi/6, 0, 0, -0.1]).reshape(-1, 1) 
      sit_mode_initial_guess_new = np.hstack((sit_mode_initial_guess_x0_new, sit_mode_initial_guess_xf_new))
      
      # Update the initial guess for the sit mode with the new initial guess
      mode_sit.initial_x_guess = sit_mode_initial_guess_new
      
    3. Control Weights:

      • Issue: You initially set R_weights_init = (1, 1, 1) and then comment out the code that updates the control weights to R_weights = (1, 3, 1). This means the control weights are never actually updated.
      • Suggestion: Uncomment and correctly update the control weights before resolving the optimisation problem.
      # Update the control weights
      sts_optimizer_new.R = np.diag(R_weights)  # Update the control weights
      hybrid_optimizer_new._setup_objective()  # Re-setup the objective function with the new weights
      
    4. Constraint Functions:

      • Issue: Ensure that the constraint functions are correctly defined and are sensitive to changes in SEAT_POS. If the constraints do not depend on SEAT_POS, changing it will not affect the results
      • Suggestion: Verify that seat_contact_no_slip_constraint_fn, sit_path_constraint_fn, and other constraint functions correctly incorporate SEAT_POS.
    5. Optimizer Settings:

      • Issue: The solver settings might be too aggressive or not sensitive enough to detect changes.
      • Suggestion: Adjust the solver tolerance and print level to ensure the solver is not terminating prematurely.
      solver_options = {
          'ipopt.print_level': 5,
          'ipopt.max_iter': 5000,  # Increase the maximum iterations
          'ipopt.fixed_variable_treatment': 'relax_bounds',
          'ipopt.tol': 1E-6,  # Decrease the tolerance for more precision
      }
      

    Updated Code Section

    Here is the updated section of the code incorporating the suggestions:

    # Update the seat position
    SEAT_POS_NEW = (-0.4, 0.2)  # New seat position
    
    # Update joint angles for the new seat position
    j1_new, j2_new = solve_ik_optimization(*SEAT_POS_NEW, lleg.l, uleg.l)
    # Adjust the joint angles to match STS convention
    j2_new = j1_new + j2_new - np.pi/2
    j1_new = j1_new - np.pi/2
    print(j1_new, j2_new)
    sit_mode_initial_guess_x0_new = np.array([j1_new, j2_new, -0.01, 0, 0, 0]).reshape(-1, 1) 
    sit_mode_initial_guess_xf_new = np.array([j1_new, j2_new, -np.pi/6, 0, 0, -0.1]).reshape(-1, 1) 
    sit_mode_initial_guess_new = np.hstack((sit_mode_initial_guess_x0_new, sit_mode_initial_guess_xf_new))
    
    # Update the initial guess for the sit mode with the new initial guess
    mode_sit.initial_x_guess = sit_mode_initial_guess_new
    mode_stand.initial_x_guess = solution['states'][1]
    
    # Create the new STS system with the updated seat position
    sts_new = STS(link1=lleg, link2=uleg, link3=torso,
                  mu=MU, seat_pos=SEAT_POS_NEW, foot_x_lims=FOOT_X_LIMS)
    sts_optimizer_new = STSTrajectoryOptimizer(sts_new,
                                            control_weights=R_weights_init,
    )
    
    # Update the control weights
    sts_optimizer_new.R = np.diag(R_weights)  # Update the control weights
    hybrid_optimizer_new._setup_objective()  # Re-setup the objective function with the new weights
    
    # Update the hybrid system parameters with the new system
    hybrid_params_new = HybridSystemParams(
        mode_sequence=[mode_sit, mode_stand],
        transitions=[transition_sit_stand],
        x0=x0,  # Initial state
        xf=xf,  # Final state
        T_ub=T_UB,  # Upper bound on total time
        min_time_step=1E-6,
        num_knot_points_per_segment=N_knots,  # Number of knot points per segment
    )
    
    # Recreate the hybrid optimizer with the new system
    hybrid_optimizer_new = HybridTrajectoryOptimizer(
        params=hybrid_params_new,
        cost_fn=sts_optimizer_new.cost_function,
        global_constraints_fns=[sts_optimizer_new.base_contact_no_slip_global_constraint_fn,
                                sts_optimizer_new.COP_global_constraint_fn,
                                sts_optimizer_new.equal_time_segment_global_constraint_fn,
                                sts_optimizer_new.control_effort_vanishes_global_constraint_fn,
                                ],
    )
    
    # Adjust solver options for more precision
    solver_options = {
        'ipopt.print_level': 5,
        'ipopt.max_iter': 5000,
        'ipopt.fixed_variable_treatment': 'relax_bounds',
        'ipopt.tol': 1E-6,
    }
    
    # Solve the optimization problem again with the new system
    solution = hybrid_optimizer_new.solve(solver_name=solver_name, opts=solver_options)
    

    Conclusion

    By ensuring the seat position is correctly updated, adjusting the initial guesses for the new configuration, updating the control weights, and tweaking the solver settings, you should see different results between the two runs as expected.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.