Parent Directory
|
Revision Log
New problems for the library.
1 ##DESCRIPTION 2 ## Evaluation of a simple algebraic expression 3 ##ENDDESCRIPTION 4 5 ##KEYWORDS('percent') 6 7 # 8 # First comes some stuff that appears at the beginning of every problem 9 # 10 11 DOCUMENT(); # This should be the first executable line in the problem. 12 13 loadMacros( 14 "PG.pl", 15 "PGbasicmacros.pl", 16 "PGchoicemacros.pl", 17 "PGanswermacros.pl", 18 "PGauxiliaryFunctions.pl", 19 "PGmatrixmacros.pl", 20 "LinearProgramming.pl", 21 "PGasu.pl" 22 ); 23 24 TEXT(&beginproblem); 25 install_problem_grader(~~&std_problem_grader); 26 $showPartialCorrectAnswers=0; 27 28 $r[0] = random(2,10); 29 for $j (1..4) { do {$r[$j] = random(2,10);} until ($r[$j] != $r[$j-1]);} 30 31 $b = random(5,10); 32 $a = random(2,5); 33 34 $c = int($b/$a)+ random(1,10); 35 36 $e = random(1,3); 37 $g = random(1,3); 38 $f = random(1,2); 39 do { $f++; } until ($f*$r[1]>$g); 40 41 $fun = nicestring([$e, $f, $g], ['x_1', 'x_2', 'x_3']); 42 43 BEGIN_TEXT 44 Use the mixed-constraint simplex method to minimize 45 \[ P = $fun \] 46 subject to 47 \[ 48 \begin{array}{rrrrrrr} 49 $r[0] x_1 & - & x_2 & - & $r[1] x_3 &\le & - $c \cr 50 x_1 & + & $a x_2 & + & $r[2] x_3 &\ge & $b \cr 51 x_1 & - & x_2 & + & $r[3] x_3 &\le & $r[4] \cr 52 \end{array} 53 \] 54 $BR 55 \[ x_1 \ge 0\ \qquad x_2 \ge 0 \ \qquad x_3 \ge 0\] 56 $BR$BR 57 If there are no solutions, enter $BITALIC None$EITALIC for \(P\). 58 $BR$BR 59 \( P = \) \{ans_rule(40)\} 60 $BR$BR 61 For the minimum value, enter the values of \(x_1\), \(x_2\), and \(x_3\) 62 in the spaces provided. If there are no solutions, you may leave these 63 answers blank. 64 $BR$BR 65 \( x_1 = \) \{ans_rule(40)\} 66 $BR$BR 67 \( x_2 = \) \{ans_rule(40)\} 68 $BR$BR 69 \( x_3 = \) \{ans_rule(40)\} 70 END_TEXT 71 72 73 74 $newsys = [[0, -$r[0], 1, $r[1], -1, 0, 0, $c], 75 [0, -1-$a*$r[0], 0, $a*$r[1]-$r[2], -$a, 1, 0, -$b+$a*$c], 76 [0, 1-$r[0], 0, $r[1]+$r[3], -1, 0, 1, $c+$r[4]], 77 [1, $e+$f*$r[0], 0, $g-$f*$r[1], $f, 0, 0, -$c*$f]]; 78 79 for $j (0..3) { 80 for $k (0..7) { 81 $newsys->[$j][$k] = new Fraction($newsys->[$j][$k],1); 82 }} 83 84 ($newsys,$endcode,$pcount) = lp_solve($newsys, fraction_mode=>1); 85 86 $fin0 = lp_current_value(0, $newsys); 87 $fin0 = ($fin0->times(-1))->print_inline(); 88 $fin1 = lp_current_value(1, $newsys)->print_inline(); 89 $fin2 = lp_current_value(2, $newsys)->print_inline(); 90 $fin3 = lp_current_value(3, $newsys)->print_inline(); 91 92 93 94 ANS(num_cmp($fin0, strings=>['None'])); 95 ANS(num_cmp($fin1)); 96 ANS(num_cmp($fin2)); 97 ANS(num_cmp($fin3)); 98 99 ENDDOCUMENT(); # This should be the last executable line in the problem. 100
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |