Question: # Load the required library library ( lpSolve ) ## Warning: package 'lpSolve' was built under R version 4 . 3 . 3 # Step
# Load the required library librarylpSolve ## Warning: package 'lpSolve' was built under R version # Step : Generate Random Data for Students set.seed # For reproducibility students data.frame GPA runif # Random GPA between and Skills sample: replace TRUE # Random Skills Relevance to Collaboration sample: replace TRUE # Random Collaboration Score to # Step : Calculate Success Score students$SuccessScore students$GPA students$Skills students$Collaboration # Step : Define Optimization Problem # Number of students and groups numstudents nrowstudents numgroups # Objective coefficients: Repeat success scores for each group objectivecoefficients repstudents$SuccessScore, each numgroups # Group size constraints groupsizeconstraints matrix nrow numgroups, ncol numstudents numgroups for j in :numgroups groupsizeconstraintsjj numstudents :j numstudents # Student assignment constraints studentassignmentconstraints matrix nrow numstudents, ncol numstudents numgroups for i in :numstudents studentassignmentconstraintsi seqi by numstudents, length.out numgroups # Combine constraints constraints rbindgroupsizeconstraints, studentassignmentconstraints # Righthand side of constraints rhs crep numgroups rep numstudents # Constraint directions constraintdirections rep lengthrhs # Debugging Outputs catDebugging Outputs:
## Debugging Outputs: catDimensions of constraints matrix:", dimconstraints
## Dimensions of constraints matrix: catLength of rhs: lengthrhs
## Length of rhs: cat
Constraints Matrix:
## ## Constraints Matrix: printconstraints ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
