代写instructions代做Python语言

instructions

February 25, 2025

1 Coursework

This coursework is linked to the Simplex  Method.  In theory the worst case complexity of the Simplex Method is O(n!).  That is, the computational cost grows factorially with the number of decision variables. However, in practical cases the complexity is often much less.  Here we will study how much less.

You will

1.  code, in Python, alternative pivoting rules for the Simplex Method;

2.  run the different rules on multiple different linear programs with different numbers of decision variables, outputting the run-time data as an Excel spreadsheet;

3.  within Excel, compute the average and worst case run-time as a function of the instance size;

4.  within Excel, produce plots showing (quantitatively) the complexity;

5.  within LaTeX, write a report analysing the pivoting rules, including your analysis using tables and plots.

1.1 Algorithms

The  Simplex  Method performs pivoting operations swapping an index between the basic set  B and its complement N. The pivoting rule chooses a (row, column) pair (r, s).  Given that pivot entry, row operations are performed so that the tableau entry a-℃s → 1, and all other entries in that column, a-is , i ≠ r → 0.

In the theory part of the course the pivoting rule shown was Bland’s rule, also called the smallest subscript rule.  This first chooses s to be the smallest  (column) index with negative reduced costs C-s  < 0. The rule next chooses r to be the smallest (row) index that satisfies the minimum ratio test.

1.1.1 Largest subscript rule

Symmetry suggests there should be nothing special about using the smallest subscript.  A first guess suggests that using the largest subscript should work just as well.

In the largest subscript rule, we first choose s to be the largest column index with negative reduced costs. The rule next chooses r to be the largest row index that satisfies the minimum ratio test.

1.1.2 Largest coefficient rule

Ideally we want to improve the objective function as much as possible.  We might hope that the size of the reduced cost coefficient is related to its impact on the objective function.

In the largest coefficient rule, we first choose s to be the column index with the most negative reduced costs. This can also be thought of as the column index with negative reduced costs and the largest magnitude.  The rule next chooses r to be the largest row index that satisfies the minimum ratio test.

1.2 Python

On Noteable you will find code implementing the (one phase) Simplex Method and Bland’s rule.

The function simplex takes as input the tableau (in basic form), the initial basis (as a list of integer indexes), and a function that implements the pivoting rule. It returns the solution as a dictionary containing its status  (did it succeed), the optimal solution, and the final basis.  This function is defined in the simplex_generation.py file: you should not modify it.

The function find_pivot_bland implements Bland’s rule.  It takes as input the tableau, and returns the  (r, s) pair giving the row and column indexes on which to pivot.  This function is defined in the simplex.ipynb notebook.  You should not modify this function, but you will need to edit code later in this notebook.

1.2.1 Task 1

At the top of the file there is an integer variable student_id = 12345678

You must replace this number with your own eight digit ID. This is used to generate the problems the Simplex Method will solve.

1.2.2 Task 2

Using find_pivot_bland as a template, you should implement find_pivot_largest_subscript and find_pivot_largest_coefficient.  This should  be done within the simplex.ipynb note- book. Function stubs are given.  The functions should implement the largest subscript rule and the largest coefficient rule given above.

There are tests on within the notebook that perform very basic checks of the code:  they do not guarantee complete correctness.

1.2.3 Task 3

It is essential that you complete task 1 before doing this step.

In the Settings section of the notebook there is a boolean variable set, as run_timings = False

Once you are happy with your code, change this to run_timings = True

When you run the full notebook,  particularly the last cell, it will produce a spreadsheet.  This should take no more than one minute  (on Noteable:  times will vary on other machines).  At the end it will have produced an Excel spreadsheet timings.xlsx.

Note:  if you cannot complete task 2, or want to continue on with the analysis before completing it, in the Settings section of the notebook there are boolean variables

time_largest_subscript. = True

time_largest_coefficient = True

By setting the appropriate variable to False, for example,

time_largest_subscript. = False

a spreadsheet creating the timing data without using that pivoting rule will be produced.

1.3 Excel

The timing data in the Excel spreadsheet was created by looping over a range of problem sizes (quantified by the number of decision variables n; the number of constraints was set to n+5).  For each problem size, 50 instances were created. For each instance the simplex method was run using both Bland’s rule and the largest coefficient rule.

The spreadsheet contains one sheets for each of the pivoting rules.  On each sheet, each row contains the times to solve each individual instance.  The first column gives the instance size; the next 50 columns gives the times.

1.3.1 Task 4

Download the spreadsheet from Noteable.  Duplicate it and rename it analysis.xlsx.  Load the duplicate analysis.xlsx into Excel.  Create a new sheet in the workbook; call it Analysis.

Using  appropriate  Excel  functions,  add  seven  columns  to  this  sheet.     The  first  should  con- tain  the  instance  sizes  n.   The  next  six  should  contain  the  average  time  and  worst-case  time for each pivoting rule  and  instance  size  (Smallest subscript. Average,  Largest subscript.

Average, Largest coefficient: Average,  Smallest subscript. Worst,  Largest subscript.: Worst, Largest coefficient: Worst).

From these, create seven more columns containing the logarithms  (base  10) of n and each time respectively.

1.3.2 Task 5

Create two plots.  One should plot the  (logarithm of the) average run time for each pivoting rule as a function of the (logarithm of the) instance size.  The other should plot the (logarithm of the) worst case run time for each pivoting rule as a function of the  (logarithm of the) instance size. Both plots should be appropriately labelled and include trend lines for each pivoting rule.

Save your figures in pdf or png format (pdf is preferred where possible).

1.3.3 Task 6

Using appropriate functions (e.g., INTERCEPT, SLOPE), compute the best fit coefficients for

log(t) = p0 log(n) + p1 ,

where t is the timing data and n is the instance sizes.  There should be different coefficients for each pivoting rule and for the average and worst cases (so six pairs of coefficients in total).

1.4 LaTeX

On Overleaf there is a report template.  The report template can be found here.  From the Overleaf menu (top left) you can Copy Project to your account so you can edit your personal version. You need to complete the report to communicate your results.

1.4.1 Task 7

In  the  first  section  of  the  LaTeX  document,   include  your  Python  code  for  the  functions find_pivot_largest_subscript and find_pivot_largest_coefficient.

1.4.2 Task 8

In the second section of the LaTeX document, using big O notation, analyse your Python codes.

1.4.3 Task 9

In the third section of your LaTeX document, include the figures created in Excel.  Add captions explaining what each is.

Also in the third section, add a table reporting the p0,1  coefficients computed in task 6.

1.4.4 Task 10

In the fourth and final section of the LaTeX document, write one paragraph to explain which of the pivoting rules is more efficient in which cases. You should use the results from the complexity analysis in task 8, and your figures and table in task 9, to back up your statements.

1.5 Submission

All work should be submitted through Blackboard.

The notebook should also be submitted through Noteable. Before submitting through Noteable, ensure that the boolean variable is reset, so run_timings = False.

Five “things” need submitting.

1.  The simplex.ipynb notebook.

2.  The (unmodified) timings.xlsx spreadsheet created by simplex.ipynb.

3.  The Excel spreadsheet with the completed analysis, analysis.xlsx.

4.  All LaTeX and figure files needed to create the report, as a zip file.  If Overleaf was used, go to the Menu (top left),  and from Download select  Source.   This zip file should contain everything needed.

5.  The report as a pdf file. If Overleaf was used, go the the Menu (top left), and from Download select PDF.

1.6 Marking scheme (rough)

[8 marks] Python code runs correctly

[2 marks] Python code documented correctly

[4 marks] Excel data analysis organised correctly

[4 marks] Excel figures created, labelled, with trend lines, correctly

[2 marks] Intercept and slope used correctly

[4 marks] LaTeX document compiles without errors

[2 marks] Python code reported in document

[5 marks] Complexity analysis correct

[2 marks] Figures included correctly, with captions

[2 marks] Table created correctly, with caption

[5 marks] Efficiency argument reasonable, supported by evidence






热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图