文档库 最新最全的文档下载
当前位置:文档库 › 货郎的故事

货郎的故事

货郎的故事
货郎的故事

The Bagman's Story

One winter’s evening, about five o’clock, just as it began to grow dusk, a ma n in a gig might have been seen urging his tired horse along the road which lea ds across Marlborough Downs, in the direction of Bristol. I say he might have b een seen, and I have no doubt he would have been, if anybody but a blind man ha d happened to pass that way; but the weather was so bad, and the night so cold and wet, that nothing was out but the water, and so the traveller jogged along in the middle of the road, lonesome and dreary enough. If any bagman of that da y could have caught sight of the little neck-or-nothing sort of gig, with a cla y-coloured body and red wheels, and the vixenish ill-tempered, fast-going bay m are, that looked like a cross between a butcher’s horse and a two-penny post-o ffice pony, he would have known at once, that this traveller could have been no other than Tom Smart, of the great house of Bilson and Slum, Cateaton Street, City. However, as there was no bagman to look on, nobody knew anything at all a bout the matter; and so Tom Smart and his clay-coloured gig with the red wheels, and the vixenish mare with the fast pace, went on together, keeping the secret among them: and nobody was a bit the wiser.

There are many pleasanter places even in this dreary world, than Marlborough Do wns when it blows hard; and if you throw in beside, a gloomy winter’s evening, a miry and sloppy road, and a pelting fall of heavy rain, and try the effect, b y way of experiment, in your own proper person, you will experience the full fo rce of this observation.

The wind blew—not up the road or down it, though that’s bad enough, but sheer across it, sending the rain slanting down like the lines they used to rule in t he copy-books at school, to make the boys slope well. For a moment it would die away, and the traveller would begin to delude himself into the belief that, ex hausted with its previous fury, it had quietly lain itself down to rest, when, whoo ! he would hear it growling and whistling in the distance, and on it would come rushing over the hill-tops, and sweeping along the plain, gathering sound and strength as it drew nearer, until it dashed with a heavy gust against hors e and man, driving the sharp rain into their ears, and its cold damp breath int o their very bones; and past them it would scour, far, far away, with a stunnin g roar, as if in ridicule of their weakness, and triumphant in the consciousnes s of its own strength and power.

The bay mare splashed away, through the mud and water, with drooping ears; now and then tossing her head as if to express her disgust at this very ungentleman ly behaviour of the elements, but keeping a good pace notwithstanding, until a gust of wind, more furious than any that had yet assailed them, caused her to s top suddenly and plant her four feet firmly against the ground, to prevent her being blown over. It’s a special mercy that she did this, for if she had been

blown over, the vixenish mare was so light, and the gig was so light, and Tom S mart such a light weight into the bargain, that they must infallibly have all g one rolling over and over together, until they reached the confines of earth, o r until the wind fell; and in either case the probability is, that neither the vixenish mare, nor the claycoloured gig with the red wheels, nor Tom Smart, wou ld ever have been fit for service again.

‘Well, damn my straps and whiskers,’ says Tom Smart (Tom sometimes had an unp leasant knack of swearing), ‘Damn my straps and whiskers,’ says Tom, ‘if thi s ain’t pleasant, blow me!’

You’ll very likely ask m e why, as Tom Smart had been pretty well blown already, he expressed this wish to be submitted to the same process again. I can’t say —all I know is, that Tom Smart said so—or at least he always told my uncle he said so, and it’s just the same thing.

‘Blow me,’ says Tom Smart; and the mare neighed as if she were precisely of t he same opinion.

‘Cheer up, old girl,’ said Tom, patting the bay mare on the neck with the end of his whip. ‘It won’t do pushing on, such a night as this; the first house w e come to we’ll put up at, so the faster you go the sooner it’s over. Soho, o ld girl—gently—gently.’

Whether the vixenish mare was sufficiently well acquainted with the tones of To m’s voice to comprehend his meaning, or whether she found it colder standing s till than moving on, of course I can’t say. But I can say that Tom had no soon er finished speaking, than she pricked up her ears, and started forward at a sp eed which made the clay-coloured gig rattle till you would have supposed every one of the red spokes were going to fly out on the turf of Marlborough Downs; a nd even Tom, whip as he was, couldn’t stop or check her pace, until she drew u p, of her own accord, before a road-side inn on the right-hand side of the way, about half a quarter of a mile from the end of the Downs.

Tom cast a hasty glance at the upper part of the house as he threw the reins to the hostler, and stuck the whip in the box. It was a strange old place, built of a kind of shingle, inlaid, as it were, with cross- beams, with gabled-topped windows projecting completely over the pathway, and a low door with a dark por ch, and a couple of steep steps leading down into the house, instead of the mod ern fashion of half a dozen shallow ones leading up to it. It was a comfortable -looking place though, for there was a strong cheerful light in the bar-window, which shed a bright ray across the road, and even lighted up the hedge on the other side; and there was a red flickering light in the opposite window, one mo ment but faintly discernible, and the next gleaming strongly through the drawn curtains, which intimated that a rousing fire was blazing within. Marking these

little evidences with the eye of an experienced traveller, Tom dismounted with as much agility as his half-frozen limbs would permit, and entered the house.

In less than five minutes’ time, Tom was esconced in the room opposite the bar —the very room where he had imagined the fire blazing—before a substantial ma tter-of-fact roaring fire, composed of something short of a bushel of coals, an d wood enough to make half a dozen decent gooseberry bushes, piled half-way up the chimney, and roaring and crackling with a sound that of itself would have w armed the heart of any reasonable man. This was comfortable, but this was not a ll, for a smartly-dressed girl, with a bright eye and a neat ankle, was laying a very clean white cloth on the table; and as Tom sat with his slippered feet o n the fender, and his back to the open door, he saw a charming prospect of the bar reflected in the glass over the chimney-piece, with delightful rows of gree n bottles and gold labels, together with jars of pickles and preserves, and che eses and boiled hams, and rounds of beef, arranged on shelves in the most tempt ing and delicious array. Well, this was comfortable too; but even this was not all—for in the bar, seated at tea at the nicest possible little table, drawn c lose up before the brightest possible little fire, was a buxom widow of somewhe re about eight and forty or thereabouts, with a face as comfortable as the bar, who was evidently the landlady of the house, and the supreme ruler over all th ese agreeable possessions. There was only one drawback to the beauty of the who le picture, and that was a tall man—a very tall man —in a brown coat and brig ht basket buttons, and black whiskers, and wavy black hair, who was seated at t ea with the widow, and who it required no great penetration to discover was in a fair way of persuading her to be a widow no longer, but to confer upon him th e privilege of sitting down in that bar, for and during the whole remainder of the term of his natural life.

Tom Smart was by no means of an irritable or envious disposition, but somehow o r other the tall man with the brown coat and the bright basket buttons did rous e what little gall he had in his composition, and did make him feel extremely i ndignant: the more especially as he could now and then observe, from his seat b efore the glass, certain little affectionate familiarities passing between the tall man and the widow, which sufficiently denoted that the tall man was as hig h in favour as he was in size. Tom was fond of hot punch—I may venture to say he was very fond of hot punch—and after he had seen the vixenish mare well fed and well littered down, and had eaten every bit of the nice little hot dinner which the widow tossed up for him with her own hands, he just ordered a tumbler of it, by way of experiment. Now, if there was one thing in the whole range of domestic art, which the widow could manufacture better than another, it was th is identical arti cle; and the first tumbler was adapted to Tom Smart’s taste w ith such peculiar nicety, that he ordered a second with the least possible dela y. Hot punch is a pleasant thing, gentlemen—an extremely pleasant thing under any circumstances—but in that snug old parlour, before the roaring fire, with the wind blowing outside till every timber in the old house creaked again, Tom

Smart found it perfectly delightful. He ordered another tumbler, and then anoth er—I am not quite certain whether he didn’t order another after that—but the more he drank of the hot punch, the more he thought of the tall man.

‘Confound his impudence!’ said Tom to himself, ‘what business has he in that snug bar? Such an ugly villain too!’ said Tom. ‘If the widow had any taste, s he might surel y pick up some better fellow than that.’Here Tom’s eye wandere d from the glass on the chimney-piece, to the glass on the table; and as he fel t himself become gradually sentimental, he emptied the fourth tumbler of punch and ordered a fifth.

Tom Smart, gentlemen, had always been very much attached to the public line. It had long been his ambition to stand in a bar of his own, in a green coat, knee -cords, and tops. He had a great notion of taking the chair at convivial dinner s, and he had often thought how well he could preside in a room of his own in t he talking way, and what a capital example he could set to his customers in the drinking department. All these things passed rapidly through Tom’s mind as he sat drinking the hot punch by the roaring fire, and he felt very justly and pro perly indignant that the tall man should be in a fair way of keeping such an ex cellent house, while he, Tom Smart, was as far from it as ever. So, after delib erating over the last two tumblers, whether he hadn’t a perfect right t o pick a quarrel with the tall man for having contrived to get into the good graces of the buxom widow, Tom Smart at last arrived at the satisfactory conclusion that he was a very ill-used and persecuted individual, and had better go to bed.

Up a wide and ancient staircase the smart girl preceded Tom, shading the chambe r candle with her hand, to protect it from the currents of air which in such a rambling old place might have found plenty of room to disport themselves in, wi thout blowing the candle out, but which did blow it out nevertheless; thus affo rding Tom’s enemies an opportunity of asserting that it was he, and not the wi nd, who extinguished the candle, and that while he pretended to be blowing it a light again, he was in fact kissing the girl. Be this as it may, another light was obtained, and Tom was conducted through a maze of rooms, and a labyrinth of passages, to the apartment which had been prepared for his reception, where th e girl bade him good night, and left him alone.

It was a good large room with big closets, and a bed which might have served fo r a whole boarding- school, to say nothing of a couple of oaken presses that wo uld have held the baggage of a small army; but what struck Tom’s fancy most wa s a strange, grim-looking high-backed chair, carved in the most fantastic manne r, with a flowered damask cushion, and the round knobs at the bottom of the leg s carefully tied up in red cloth, as if it had got the gout in its toes. Of any other queer chair, Tom would only have thought it was a queer chair, and there would have been an end of the matter; but there was something about this parti cular chair, and yet he couldn’t tell what it was, so odd and so unlike any ot

her piece of furniture he had ever seen, that it seemed to fascinate him. He sa t down before the fire, and stared at the old chair for half an hour;—Deuce ta ke the chair, it was such a strange old thing, he couldn’t take his eyes off i t.

‘Well,’ said Tom, slowly undressing himself, and staring at the old chair all the while, which stood with a mysterious aspect by the bedside, ‘I never saw s uch a rum concern as that in my days. Very odd,’ said Tom, who had got rather sage with the hot punch, ‘Very odd.’ Tom shook his head with an air of profou nd wisdom, and looked at the chair again. He c ouldn’t make anything of it thou gh, so he got into bed, covered himself up warm, and fell asleep.

In about half an hour Tom woke up, with a start, from a confused dream of tall men and tumblers of punch; and the first object that presented itself to his wa king imagination was the queer chair.

‘I won’t look at it any more,’ said Tom to himself, and he squeezed his eyel ids together, and tried to persuade himself he was going to sleep again. No use; nothing but queer chairs danced before his eyes, kicking up their legs, jumpin g over each other’s backs, and playing all kinds of antics.

‘I may as well see one real chair, as two or three complete sets of false one s,’ said Tom, bringing out his head from under the bed-clothes. There it was, plainly discernible by the light of the fire, looking as provoking as ever.

Tom gazed at the chair; and, suddenly as he looked at it, a most extraordinary change seemed to come over it. The carving of the back gradually assumed the li neaments and expression of an old shrivelled human face; the damask cushion bec ame an antique, flapped waistcoat; the round knobs grew into a couple of feet, encased in red cloth slippers; and the old chair looked like a very ugly old ma n, of the previous century, with his arms a-kimbo. Tom sat up in bed, and rubbe d his eyes to dispel the illusion. No. The chair was an ugly old gentleman; and what was more, he was winking at Tom Smart.

Tom was naturally a headlong, careless sort of dog, and he had had five tumbler s of hot punch into the bargain; so, although he was a little startled at first, he began to grow rather indignant when he saw the old gentleman winking and le ering at him with such an impudent air. At length he resolved that he wouldn’t stand it; and as the old face still kept winking away as fast as ever, Tom said, in a very angry tone:

‘What the devil are you winking at me for?’

‘Because I like it, Tom Smart,’ said the chair; or the old gentleman, whichev er you like to call him. He stopped winking though, when Tom spoke, and began g rinning like a superannuated m&#111nkey.

‘How do you know my name, old nut-cracker face!’ inquired Tom Smart, rather s taggered;—though he pretended to carry it off so well.

‘Come, come, Tom,’ said the old gentleman, ‘that’s not the way to address s olid Spanish Mah ogany. Dam’me, you couldn’t treat me with less respect if I w as veneered.’ When the old gentleman said this, he looked so fierce that Tom b egan to be frightened.

‘I didn’t mean to treat you with any disrespect, sir,’ said Tom; in a much h umbler tone than he had spoken in at first.

‘Well, well,’ said the old fellow, ‘perhaps not—perhaps not. Tom—.’

‘Sir—’

‘I know everything about you, Tom; everything. You’re very poor, Tom.’

‘I certainly am,’ said Tom Smart. ‘But how came you to know that?’

‘Never mind that,’ said the old gentleman; ‘you’re much too fond of punch, Tom.’

Tom Smart was just on the point of protesting that he hadn’t tasted a drop sin ce his last birthday, but when his eye encountered that of the old gentleman, h e looked so knowing that Tom blushed, and was silent.

‘Tom,’ said the old gentleman, ‘the widow’s a fine woman—remarkably fine w oman—eh, Tom?’ Here the old fellow screwed up his eyes, cocked up one of his wasted little legs, and looked altogether so unpleasantly amorous, that Tom was quite disgusted with the levity of his behaviour;—at his time of life, too!

‘I am her guardian, Tom,’ said the old gentleman.

‘Are you?’ inquired Tom Smart.

‘I knew her mother, Tom,’ said the old fellow; ‘and her grandmother. She was very fond of me—made me this waistcoat, Tom.’

‘Did she?’ said Tom Smart.

‘And these shoes,’ said the old fellow, lifting up one of the red-cloth muffl ers; ‘but don’t mention it, Tom. I shouldn’t like to have it known that she

was so much attached to me. It might occasion some unpleasantness in the famil y.’ When the old rascal said this, he looked so extremely impertinent, that, a

s Tom Smart afterwards declared, he could have sat upon him without remorse.

‘I have been a great favourite among the women in my time, Tom,’ said the pro flig ate old debauchee; ‘hundreds of fine women have sat in my lap for hours to gether. What do you think of that, you dog, eh!’ The old gentleman was proceed ing to recount some other exploits of his youth, when he was seized with such a violent fit of creaking that he was unable to proceed.

‘Just serves you right, old boy,’ thought Tom Smart; but he didn’t say anyth ing.

‘Ah!’ said the old fellow, ‘I am a good deal troubled with this now. I am ge tting old, Tom, and have lost nearly all my rails. I have had an operation perf ormed, too—a small piece let into my back—and I found it a severe trial, Tom.’

‘I dare say you did, sir,’ said Tom Smart.

‘However,’ said the old gentleman, ‘that’s not the point Tom! I want you to marry the widow.’

‘Me, sir! said Tom.

‘You;’ sa id the old gentleman.

‘Bless your reverend locks,’ said Tom—(he had a few scattered horse-hairs le ft), ‘bless your reverend locks, she wouldn’t have me.’ And Tom sighed invol untarily, as he thought of the bar.

‘Wouldn’t she?’ said the old gentleman, firmly.

‘No, no,’ said Tom; ‘there’s somebody else in the wind. A tall man—a confo undedly tall man—with black whiskers.’

‘Tom,’ said the old gentleman; ‘she will never have him.’

‘Won’t she?’ said Tom. ‘If you stood in the bar, old gentleman, you’d tell another story.’

‘Pooh, pooh,’ said the old gentleman. ‘I know all about that.’

‘About what?’ said Tom.

‘The kissing behind the door, and all that sort of thing, Tom,’ said the old gentleman. And here he gave another impudent look, which made Tom very wroth, b

ecause as you all know, gentlemen, to hear an old fellow, who ought to know bet ter, talking about these things, is very unpleasant—nothing more so.

‘I know all about that, Tom,’ said the old gentleman. ‘I have seen it done v ery often in my time, Tom, between more people than I should like to mention to you; but it never came to anything after all.’

‘You must have seen some queer things,’ said Tom, with an inquisitive look.

‘You may say that, now,’ replied the old fellow, with a very complicated wink.‘I am the last of my family, Tom,’ said the old gentleman, with a melancholy sigh.

‘Was it a large one?’ inquired Tom Smart.

‘There were twelve of us, Tom,’ said the old gentleman; ‘fine straight-backe d, handsome fellows as you’d wish to see. None of your modern abortions—all w ith arms, and with a degree of polish, though I say it that should not, which w ould have done your heart good to behold.’

‘And what’s become of the others, sir?’ asked Tom Smart.

The old gentleman applied his elbow to his eye as he replied, ‘Gone, Tom, gone. We had hard service, Tom, and they hadn’t all my constitution. They got rheum atic about the legs and arms, and went into kitchens and other hospitals; and one of ’em, with long service and hard usage, positively lost his senses:—he got so crazy that he was obliged to be burnt. Shocking thing that, Tom.’

‘Dreadful!’ said Tom Smart.

The old fellow paused for a few minutes, apparently struggling with his feeling s of emotion, and then said:

‘However, Tom, I am wandering from the point. This tall man, Tom, is a rascall y adventurer. The moment he married the widow, he would sell off all the furnit ure, and run away. What would be the consequence? She would be deserted and red uced to ruin, and I should catch my death of cold in some broker’s shop.’

‘Yes, but—’

‘Don’t interrupt me,’ said the old gentleman. ‘Of you, Tom, I entertain a v ery different opinion; for I well know that if you once settled yourself in a p ublic-house, you would never leave it, as long as there was anything to drink w ithin it s walls.’

‘I am very much obliged to you for your good opinion, sir,’ said Tom Smart.

‘Therefore,’ resumed the old gentleman, in a dictatorial tone; ‘you shall ha ve her, and he shall not.’

‘What is to prevent it?’ said Tom Smart, eagerly.

‘This disclosure,’ replied the old gentleman; ‘he is already married.’

‘How can I prove it?’ said Tom, starting half out of bed.

The old gentleman untucked his arm from his side, and having pointed to one of the oaken presses, immediately replaced it in its old position.

‘He little thinks,’ said the old gentleman, ‘that in the right-hand pocket o f a pair of trousers in that press, he has left a letter, entreating him to ret urn to his disconsolate wife, with six—mark me, Tom—six babes, and all of the m small ones.’

As the old gentleman solemnly uttered these words, his features grew less and l ess, distinct, and his figure more shadowy. A film came over Tom Smart’s eyes. The old man seemed gradually blending into the chair, the damask waistcoat to r esolve into a cushion, the red slippers to shrink into little red cloth bags. T he light faded gently away, and Tom Smart fell back on his pillow, and dropped asleep.

Morning aroused Tom from the lethargic slumber, into which he had fallen on the disappearance of the old man. He sat up in bed, and for some minutes vainly en deavoured to recall the events of the preceding night. Suddenly they rushed upo n him. He looked at the chair; it was a fantastic and grim-looking piece of fur niture, certainly, but it must have been a remarkably ingenious and lively imag ination, that could have discovered any resemblance between it and an old man.

‘How are you, old boy?’ said Tom. He was bolder in the daylight—most men are.

The chair remained motionless, and spoke not a word.

‘Miserable morning,’ said Tom. No. The chair would not be drawn into conversa tion.

‘Which press did you point to?—you can tell me that,’ said Tom. Devil a word, gentlemen, the chair would say. It’s not much trouble to open it, anyhow,’ s aid Tom, getting out of bed very deliberately. He walked up to one of the press es. The key was in the lock; he turned it, and opened the door. There was a pai r of trousers there. He put his hand into the pocket, and drew forth the identi cal letter the old gentleman had described!

‘Queer sort of thing, this,’ said Tom Smart; looking first at the chair and t hen at the press, and then at the letter, and then at the chair again. ‘Very q ueer,’ said Tom. But, as there was nothing in either, to lessen the queerness, he thought he might as well dress himself, and settle the tall man’s business at once—just to put him out of his misery.

Tom surveyed the rooms he passed through, on his way down stairs, with the scru tinizing eye of a landlord; thinking it not impossible, that before long, they and their contents would be his property. The tall man was standing in the snug little bar, with his hands behind him, quite at home. He grinned vacantly at T om. A casual observer might have supposed he did it, only to show his white tee th; but Tom Smart thought that a consciousness of triumph was passing through t he place where the tall man’s mind would have been, if he had had any. Tom lau ghed in his face; and summoned the landlady.

‘Good morning, ma’am,’ said Tom Smart, closing the door of the little pa rlou r as the widow entered.

‘Good morning, sir,’ said the widow. ‘What will you take for breakfast, sir?’

‘Tom was thinking how he should open the case, so he made no answer.

‘There’s a very nice him,’ said the widow, ‘and a beautiful cold larded fow l. Sha ll I send ’em in, sir?’

These words roused Tom from his reflections. His admiration of the widow increa sed as she spoke. Thoughtful creature! Comfortable provider!

‘Who is that gentleman in the bar, ma’am?’ inquired Tom.

‘His name is Jinkins, sir,’ said th e widow, slightly blushing.

‘He’s a tall man,’ said Tom.

‘He is a very fine man, sir,’ replied the widow, ‘and a very nice gentleman.’

‘Ah!’ said Tom.

‘Is there anything more you want, sir?’ inquired the widow, rather puzzled by Tom’s manner.

‘Why, yes,’ said Tom. ‘My dear ma’am, will you have the kindness to sit dow n for one moment?’

The widow looked much amazed, but she sat down, and Tom sat down too, close bes ide her. I don’t know how it happened, gentlemen—indeed my uncle used to tell

me that Tom Smart said he didn’t know how it happened either—but somehow or o ther the palm of Tom’s hand fell upon the back of the widow’s hand, and remai ned there while he spoke.

‘My dear ma’am,’ said Tom Smart—he had always a great notion of committing the amiable—‘My dear ma’am, you deserve a very excellent husband;—you do in deed.’

‘Lor, sir!’ said the widow—as well she might: Tom’s mode of commencing the conversati on being rather unusual, not to say startling; the fact of his never having set eyes upon her before the pre vious night, being taken into consideration. ‘Lor, sir!’I scorn to fla tter, my dear ma’am,’ said Tom Smart. ‘You deserve a very admirable husband, and whoever he is, he’ll be a very lucky man.’ As Tom said this his eye invol untarily wandered from the wido w’s face, to the comforts around him.

The widow looked more puzzled than ever, and made an effort to rise. Tom gently pressed her hand, as if to detain her, and she kept her seat. Widows, gentleme n, are not usually timorous, as my uncle used to say.

‘I am sure I am very much obliged to you, sir, for your good opinion,’ said t he buxom landlady, half laughing; ‘and if ever I marry again’—

‘If,’ said Tom Smart, looking very shrewdly out of the right-hand corner of h is left eye. ‘If’—

‘Well,’ said the widow, laughing outright this time. ‘When I do, I hope I sh all have as good a husband as you describe.’

‘Jinkins to wit,’ said Tom.

‘Lor, sir!’ exclaimed the widow.

‘Oh, don’t tell me,’ said Tom, ‘I know him.’

‘I am sure nobody who knows him, knows anything bad of him,’ said the widow, bridling up at the mysterious air with which Tom had spoken.

‘Hem!’ said Tom Smart.

The widow began to think it was high time to cry, so she took out her handkerch ief, and inquired whether Tom wished to insult her: whether he thought it like a gentleman to take away the character of another gentleman behind his back: wh y, if he had got anything to say, he didn’t say it to the man, like a man, ins tead of terrifying a poor weak woman in that way; and so forth.

‘I’ll say it to him fast enough,’ said Tom, ‘only I want you to hear it fir st.’

‘What is it?’ inquired the widow, looking intently in Tom’s countenance.

‘I’ll astonish you,’ said Tom, putting his hand in his pocket.

‘If it is, that he wants money,’ said the widow, ‘I know that alre ady, and y ou needn’t trouble yourself.’

‘Pooh, nonsense, that’s nothing,’ said Tom Smart. ‘I want money. ’Tan’t t hat.’

‘Oh, dear, what can it be?’ exclaimed the poor widow.

‘Don’t be frightened,’ said Tom Smart. He slowly drew forth the letter, and unfolde d it. ‘You won’t scream?’ said Tom, doubtfully.

‘No, no,’ replied the widow; ‘let me see it.’

‘You won’t go fainting away, or any of that nonsense?’ said Tom.

‘No, no,’ returned the widow, hastily.

‘And don’t run out, and blow him up,’ said Tom, ‘because I’ll do all that for you; you had better not exert yourself.’

‘Well, well,’ said the widow, ‘let me see it.’‘I will,’ replied T om Smart; and, with these words, he placed the letter in the widow’s hand.

Gentlemen, I have heard my uncle say, that Tom Smart s aid the widow’s lamentat ions when she heard the disclosure would have pierced a heart of stone. Tom was certainly very tender-hearted, but they pierced his, to the very core. The wid ow rocked herself to and fro, and wrung her hands.

‘Oh, the deception and villainy of man!’ said the widow.

‘Frightful, my dear ma’am; but compose yourself,’ said Tom Smart.

‘Oh, I can’t compose myself,’ shrieked the widow. ‘I shall never find any o ne else I can love so much!’

‘Oh yes, you will, my dear soul,’ said Tom Smart, le tting fall a shower of th e largest sized tears, in pity for the widow’s misfortunes. Tom Smart, in the energy of his compassion, had put his arm round the widow’s waist; and the wid ow, in a passion of grief, had clasped Tom’s hand. She looked up in Tom’s f ac

e, and smiled through her tears. Tom looked down in hers, and smiled through hi s.

I never could find out, gentlemen, whether Tom did or did not kiss the widow at that particular moment. He used to tell my uncle he didn’t, but I have my dou bts about it. Between ourselves, gentlemen, I rather think he did.

At all events, Tom kicked the very tall man out at the front door half an hour after, and married the widow a month after. And he used to drive about the coun try, with the clay-coloured gig with red wheels, and the vixenish mare with the fast pace, till he gave up business many years afterwards, and went to France with his wife; and then the old house was pulled down.’

货郎担问题或旅行商问题动态规划算法

#include #include #define maxsize 20 int n; int cost[maxsize][maxsize]; int visit[maxsize]={1}; //表示城市0已经被加入访问的城市之中 int start = 0; //从城市0开始 int imin(int num, int cur) { int i; if(num==1) //递归调用的出口 return cost[cur][start]; //所有节点的最后一个节点,最后返回最后一个节点到起点的路径 int mincost = 10000; for(i=0; i

{ /*if(mincost <= cost[cur][i]+cost[i][start]) { continue; //其作用为结束本次循环。即跳出循环体中下面尚未执行的语句。区别于break } */ visit[i] = 1; //递归调用时,防止重复调用 int value = cost[cur][i] + imin(num-1, i); if(mincost > value) { mincost = value; } visit[i] = 0;//本次递归调用完毕,让下次递归调用 } } return mincost;

} int main() { int i,j; // int k,e,w; n=4; int cc[4][4]={{0,10,15,20}, {5,0,9,10}, {6,13,0,12}, {8,8,9,0}}; for(i=0; i

宁波老话童谣(最全汇总)

本来要打千千万万记, 现在功夫来不及, 马马虎虎打三记, 一、二、三山里有只老虎,老虎要咬人,关辣笼子里。笼子坏脱,老虎逃脱,逃到北京,买包糖精,缺子变做活生精。 正月嘎瓜子,二月放鹞子,三月上坟带银子,四月种田下秧子,五月白糖温粽子,六月朝天扇扇子,七月西瓜吃心子,八月月饼嵌馅子,九月钓红夹柿子,十月沙泥炒栗子,十一月落雪子,十二月冻煞叫花子。 拖鼻头拖鼻头,牵黄牛,一牵牵到妈妈踏床头。帐子裢开六盆头:一盆花生,一盆豆,一盆莆齐,一盆藕,一盆水鸡炒带豆,一盆白片温酱油。 囡囡宝,侬要啥人抱?我要阿爷抱。阿爷嗤嗤困晏胶。囡囡宝,侬要啥人抱?我要阿娘抱。阿娘腰骨伛勿倒。囡囡宝,侬要啥人抱?我要阿爸抱。阿爸出门赚元宝。囡囡宝,侬要啥人抱?我要阿姆抱。阿姆纺花做棉袄。囡囡宝,侬要啥人抱?我要阿叔抱。阿叔劈柴磨柴刀。囡囡宝,侬要啥人抱?我要阿姑抱。阿姑出嫁就要到。囡囡宝,侬要啥人抱?我要阿哥抱。阿哥读书做文章。囡囡宝,派来派弃呒人抱,鞋是自介走走好。 头里一嘎草,耐尼抬阿嫂,阿嫂抬来乏夹冒,生出鱼子做强盗,生出囡做花浪 老伯伯: 从前有个老八八(伯伯), 年纪有的八十八, 来到百丈噶(街), 买了八宝粥, 用了八角八分八厘 摇呀摇摇呀摇,摇到外婆桥。外婆是介话:介坏人,要其啥? 还是斩斩喂大蛇,大蛇不要拔小蛇。小蛇囫囵吞,鲤鱼跳龙门, 一跳跳到水缸顶,倾令匡郎做大水 斗斗虫,嘟嘟飞,柯只麻雀剥剥皮,要吃吃眼去,勿吃嘟飞去。大麻雀,拖谷去,小麻雀飞来又飞去,飞到高山吃白米。 正月磕瓜子 正月磕瓜子,二月放鹞子, 三月上坟抬轿子,四月种田下秧子, 五月白糖温粽子,六月吃饭煽扇子, 七月西瓜吃心子,八月月饼嵌馅子, 九月钓红夹柿子,十月沙泥炒栗子, 十一月落雪子,十二月冻煞叫花子。 踢踢扳扳 踢踢扳扳,扳过南山, 南山北斗,至尊买牛, 牛蹄马脚,失落蹄子佝一脚。 一粒星,格楞敦; 二粒星,加油瓶。 油瓶漏,加水塔。 水塔鸟,加鹁鸪。 鹁鸪头上一滴血,拷开三斗三升血。 老鸦畜生是格坏,一拖拖到河中央。 长晾竿,撩撩撩勿起;

运筹学

一、单选题(共40 道试题,共100 分。)V 1. 对于第二类存储模型——进货能力有限,不允许缺货,下列哪项不属于起假设前提条件() A. 需求是连续,均匀的 B. 进货是连续,均匀的 C. 当存储降至零时,可以立即得到补充 D. 每个周期的定货量需要一次性进入存储,一次性满足 标准答案:D 2. 在完全不确定下的决策方法不包括下列的哪一项() A. 悲观法 B. 乐观法 C. 最大收益法 D. 等可能性法 标准答案:C 3. 所谓确定条件下的决策,是指在这种条件下,只存在() A. 一种自然状态 B. 两种自然状态 C. 三种或三种以上自然状态 D. 无穷多种自然状态 标准答案:A 4. 单纯形法的迭代计算过程是从一个可行解转换到目标函数值更大的另一个可行解。 A. 对

B. 错 标准答案:B 5. 下例错误的说法是 A. 标准型的目标函数是求最大值 B. 标准型的目标函数是求最小值 C. 标准型的常数项非正 D. 标准型的变量一定要非负 标准答案:C 6. 求般获得最好经济效益问题是求如何合理安排决策变量(即如何安排生产)使目标函数最大的问题,求最大的目标函数问题,则记为max Z;若是如何安排生产使成本是最小的问题,则记为min Z . A. 对 B. 错 标准答案:A 7. ()是用来衡量所实现过程优劣的一种数量指标 A. 状态 B. 决策 C. 状态转移 D. 指标函数 标准答案:D 8. 在实际工作中,企业为了保证生产的连续性和均衡性,需要存储一定数量的物资,对于存储方案,下列说法正确的是( )

A. 应尽可能多的存储物资,以零风险保证生产的连续性 B. 应尽可能少的存储物资,以降低库存造成的浪费 C. 应从多方面考虑,制定最优的存储方案 D. 以上说法都错误 标准答案:C 9. 约束条件为AX=b,X≥0 的线性规划问题的可行解集是() A. 补集 B. 凸集 C. 交集 D. 凹集 标准答案:B 10. 存货台套的运费应列入() A. 订货费用 B. 保管费用 C. 进厂价 D. 其它支出 标准答案:C 11. 基可行解中的非零变量的个数小于约束条件数时,该LP问题可求得( )。 A. 基本解 B. 多重解 C. 退化解 D. 无解

客家俗语辑解

客家俗语辑解 客家俗话是客家地区广为流传的民间口头语言。它凝聚了客家人文化发展成果,反映了客家人的某些观念意识,体现了客家人的情操和精神境界... (一)二字句: 1.寒酸(指小气) 2.孤寒(指小气) 3.啜壳(与“喝西北风“同义) 4.等路(即“手信“) 5.驳脚(意即续弦) 6.水客(对“专门帮助乡亲从国外带回书信、款、物的人“的称谓) 7.降子(指生孩子) 8.仙家(指潇洒的人) 9.巫斩(意即不可救药) 10.啜子(即骗子) 11.烂仔(指二流子)

12.歪仔(指调皮) 13.乓鬼(指说话不实在的人) 14.撩刁(意即惹是生非) 15.赌采(凑碰) 16.练雀(讲人爱打扮) 17.酸货(指爱讲下流话的人) (二)三字句: 1.灶下鸡、缸下拐、缩窿拐(拐“即“青蛙“,意思是指胆小怕事,不敢出门) 2.躁缸猪(胡乱动之意) 3.金乌蝇(“乌蝇“即“苍蝇“,指表里不一的人) 4.打铁老(指吃饭很多的人) 5.狐狸精、搞潭精、辘屎棍(均指为人狡猾、喜欢拨弄是非者) 6.食死佬(指光会吃饭不会做事的人) 7.苦瓜虫(指食内不食外的人) 8.鸡毛衫(指轻浮) 9.铁公鸡、石屎不(“屎不“即“屁股“,意为小气) 10.鸡妈啼(意为异常,即不祥之兆) 11.刘阿斗(指刘禅,意思为败家子)

12.面线话(指说话罗喀,跟面线一样连连牵牵) 13.车大炮(指吹牛) 14.糍粑心(心太软) 15.大水扯、搭脚头(逢人便停下来讲话,没有个完) 16.鸦片鬼(不象人样) 17.四六货(指精神不正常的人) 18.懒尸嬷(指懒惰的女人) 19.轻骨头(指不知福的人) 20.尿桶底(酒醉貌) 21.叶下桃(喻依靠父母享福) 22.烂铜锣(比喻说话不看场合) 23.阴质哥(指搞阴谋诡计的人) 24.白鼻之(败家子?quot;白“读“Pa“音) 25.送背铳(意即事后诸葛亮) 26.粘人虫、缠背狗(指小孩老缠着大人) 27.白目珠(指不孝子孙) 28.痰火鬼(指脾气坏的人) 29.屎爬虫(意即乱钻) 30 .信人拐(指相信别人欺骗) 31.狗咬狗(指坏人自相殴斗) 32.三只手(指小偷、扒手) 33.落汤鸡(狼狈相)

货郎担问题的求解

CLS PRINT”货郎担问题的穷举解法” PRINT”* * * * * * * * *”PRINT”“ INPUT”请输入全部村庄数目N=”;n DIM d(n,n):s()=0 FOR i=1TO n FOR j=1TO n READ d(i,j) IF d(i,j)>s0 THEN s0=d(i,j) NEXT j NEXT i P=1 FOR i=1TO n-3 P=p*(i+1) NEXT i DIM x(p*(n-1),n-1),f(p*(n-1)) FOR K=1 TO n-1 x(0,K)=K NEXT K FOR i=1TO n-1 FOR K=1 TO n-1 x((i-1)*p+1,K)=x((i-1)*p,K)+1 IF x((i-1)*p+1,K)>n THEN x((i-1)*p+1,K)=x((i-1)*p+1,K)-n+1 NEXT K m=n-2 FOR j=2 TO p s=d(1,i+1) FOR K=1 TO n-1 x((i-1)*p+j,K)=x((i-1)*p+j-1,K) NEXT K IF m<2 THEN m=n-2 x1=x((i-1)*p+j,m):x2=x((i-1)*p+j,n-1) x((i-1)*p+j,m)=x2;x((i-1)*p+j,n-1)=x1 m=m-1 NEXT j NEXT i

S1=s0*n: p=p*(n-1) FOR i=1TO p S=d(1,x(i,1)) FOR j=1TO n-2 s=s+d(x(i,j),x(i,j+1)) NEXT j f(i)=s+d(x(i,j),j) IFf(i)1GOTO 20 PRINT”走法” PRINT”V(1)--”; FOR i=1To n-1 PRINT”V(“;x(t,i);”)--”; NEXT i PRINT “V(1)” PRINT”最短路线:”;s1:GOTO30 20:FOR i=1TO m PRINT “第”;I;”条是:” PRINT “V(1)--”; FOR j = 1TO n-1 PRINT”V(“;x(x1(i),j);”)--”; NEXT j PRINT “V(1)” NEXT i PRINT “最短路长为:”;s1 30:END

中国美术名作赏析—《货郎图》

中国美术名作赏析—— 《货郎图》∶宫廷里为什么这么多货郎图? 南宋画家李嵩的《货郎图》,现藏在北京故宫博物院。 这件《货郎图》,绢本设色,高25.5厘米,长是70.4厘米,是一件不太大的手卷。这件作品进入了清朝的收藏,特别爱题字的乾隆皇帝也在上面题了一首诗。除了乾隆的诗,画上还有画家自己的落款,写着"嘉定辛未李从训(顺)男嵩画"———嘉定辛未年(1211),李从训的儿子李嵩画。 李嵩生活在南宋1166年到1243年间,是杭州人。他小的时候跟木工做学徒,后来父母去世得比较早,他就成了画院的画家李从训的养子。李从训亲自教他画画,他不但学会了宫廷绘画的一些门道,更学会了如何在宫廷中生存,后来也成为一名宫廷画家。 《货郎图》是一个流传很广的题材。李嵩描绘货郎的作品,不止这一件。世界上现存的李嵩的"货郎类"作品,我见过四件,分别藏在北京故宫、台北故宫、美国大都会博物馆和美国克利夫兰艺术博物馆。只有北京故宫的是一件横卷,而其他的三件都是圆形的扇子。

写实画技高超 这些作品都是用很简单的线描勾勒,有些在精细劲拔的线条旁边渲染了一些淡淡的颜色,显得很优雅。画面上,人物的动态特别有趣,不同人物各具特色,小孩充满了稚气,妇女显得端庄雍容,而货郎永远是很着急的,很关心周围的情况。 李嵩特别擅长画人物,他的宗教人物也特别有名。你从这件作品的人物刻画就可以看出,画家的写实功底相当扎实,画什么像什么。人体的比例和动态都描绘得非常精准。 李嵩还擅长界画。界画,就是画直线的时候用尺子,能把建筑、物品画得十分规整和精细。 你看,货郎担上所有的货物被描绘得一丝不苟,显示了李嵩高超的界画技巧。这些东西都很精准,你都能——辨认出来是什么东西∶有锅碗盆盘,有家用杂物,有点心、药品,有工具材料,有针头线脑,有儿童玩具,还有瓜果糕点。在货郎担上方还高高地挂着像是羽毛一样的东西,仔细辨认,好像有鸟,有水果,有波浪鼓,有碗,有水壶,有风车,有风筝,有扇子,什么都有。不光担子上,这个货郎的头上、手上、腰上都挂满了各种物品,甚至连脖子上也套上了货物,帽子上也插满了商品。如此不厌其烦的精准描绘,让你感觉到,这些物品就是作品的主体。 《货郎图》局部

22、探索法求解货郎担问题

数学与计算机学院 课程设计说明书课程名称: 算法设计与分析-课程设计 课程代码: 7106620 题目: 货郎担问题 年级/专业/班: 学生姓名: 学号: 开始时间:2010 年12 月27 日完成时间:2011 年01月07日课程设计成绩: 学习态度及平时成绩(30)技术水平与实际能 力(20) 创新(5)说明书撰写质量(45) 总分 (100) 指导教师签名:年月日

目录 1 引言 .................................................................................................................................................... - 2 - 1.1问题的提出 (2) 1.2任务与分析 (2) 2程序运行平台 ......................................................................................................................................... - 2 -3 总体设计 ................................................................................................................................................ - 3 -4程序说明 ................................................................................................................................................. - 4 - 5 模块分析 ................................................................................................................................................ - 8 - 6 系统测试 .............................................................................................................................................. - 11 - 7 结论 ...................................................................................................................................................... - 13 -参考文献 .................................................................................................................................................. - 14 -附录 .................................................................................................................................................... - 15 - - 1 -

遗传算法求解货郎担问题

[键入公司名称] 遗传算法求解TSP问题最短路径参观特定地点 [键入作者姓名] 2014/12/12 指导老师:

1 问题简介 一个考察团想参观同济大学嘉定校区,参观地点如图1黄色标注所示。他们想从其中一点出发,然后依次经过其它点,中间不重复,最后回到起点。请为他们设计一条最短路径。 图1 同济大学嘉定校区参观点 2 问题分析 这是一个典型的TSP问题。我们可以尝试采用遗传算法来解决。先随机生成若干条有效路径,再选择其中较优的路径进行繁殖,生成下一代。再对下一代进行类似的操作。进过若干代的进化后,将会收敛于一个较优解。具体的流程如图2所示。

3 实验结果 路径为:6 5 7 10 8 9 4 2 1 3 6。长度为:3.1434 Km如图3 所示。 其中,适应度函数如图4所示。 (由于起点不固定,故同一条路径有多种结果:5 7 10 8 9 2 1 3 6 5、2 1 3 6 5 7 10 8 9 4、3 6 5 7 10 8 9 4 2 1;另外,多次运行程序,还出现另一个结果:9 8 10 7 5 6 3 1 2 4、7 5 6 3 1 2 4 9 8 10。但两者的长度一样,实际中两者长度应该差不多)

图3 路径图 图4 适应度函数变化趋势图4 源程序 clc,clear;

%% 距离矩阵 MatrixDis1 = 1e3*[ 0 0.3869 0.4067 0.6400 0.7446 0.6243 0.8617 1.0931 0.6659 1.0823 0.3869 0 0.1214 0.2540 0.4282 0.3446 0.6204 0.7067 0.3057 0.7332 0.4067 0.1214 0 0.2682 0.3464 0.2420 0.5130 0.7228 0.3833 0.6766 0.6400 0.2540 0.2682 0 0.2930 0.2953 0.5320 0.4583 0.1901 0.5149 0.7446 0.4282 0.3464 0.2930 0 0.1299 0.2413 0.5530 0.4818 0.3454 0.6243 0.3446 0.2420 0.2953 0.1299 0 0.2761 0.6502 0.4803 0.4749 0.8617 0.6204 0.5130 0.5320 0.2413 0.2761 0 0.7430 0.7218 0.3984 1.0931 0.7067 0.7228 0.4583 0.5530 0.6502 0.7430 0 0.4625 0.4316 0.6659 0.3057 0.3833 0.1901 0.4818 0.4803 0.7218 0.4625 0 0.6567 1.0823 0.7332 0.6766 0.5149 0.3454 0.4749 0.3984 0.4316 0.6567 0]; N = length(MatrixDis1); %% 初始种群 Num_Population = 50; % 种群规模 Init_Population = zeros(Num_Population,N); fori = 1:Num_Population Init_Population(i,:) = randperm(N); end %% 进化过程 k = 0; Gen_Max = 1000; % 最大进化代数 Population = Init_Population; Best_Fitness = zeros(1,Gen_Max); Best_Individual = zeros(Gen_Max,N); while (k

TSP问题与LINGO求解技巧

TSP 问题及LINGO 求解技巧 巡回旅行商问题(Traveling Salesman Problem ,TSP),也称为货郎担问题。最早可以追溯到1759年Euler 提出的骑士旅行问题。1948年,由美国兰德公司推动,TSP 成为近代组合优化领域的一个典型难题。它已经被证明属于NP 难题。 用图论描述TSP ,给出一个图(,)G V E =,每边e E ∈上有非负权值()w e ,寻找G 的Hamilton 圈C ,使得C 的总权()()() W C w e e E C = ∑ ∈最小. 几十年来,出现了很多近似优化算法。如近邻法、贪心算法、最近插入法、最远插入法、模拟退火算法以及遗传算法。这里我们介绍利用LINGO 软件进行求解的方法。 问题1 设有一个售货员从10个城市中的某一个城市出发,去其它9个城市推销产品。10个城市相互距离如下表。要求每个城市到达一次仅一次后,回到原出发城市。问他应如何选择旅行路线,使总路程最短。 我们采用线性规划的方法求解 设城市之间距离用矩阵d 来表示,ij d 表示城市i 与城市j 之间的距离。设0--1矩阵X 用来表示经过的各城市之间的路线。设 01 ,ij i j x i j i j ?=? ?若城市不到城市若城市到城市且在前 考虑每个城市后只有一个城市,则: 1 1,n ij j j i x =≠=∑ 1,,i n =… 考虑每个城市前只有一个城市,则:

1 1,n ij i i j x =≠=∑ 1,,j n =…; 但仅以上约束条件不能避免在一次遍历中产生多于一个互不连通回路。 为此我们引入额外变量 i u (1,,i n =…), 附加以下充分约束条件: 1,i j ij u u nx n -+≤- 1i j n <≠≤; 该约束的解释: 如i 与j 不会构成回路,若构成回路,有: 1ij x =,1ji x =,则: 1i j u u -≤-,1j i u u -≤-,从而有: 02≤-,导致矛盾。 如i ,j 与k 不会构成回路,若构成回路,有: 1ij x =,1jk x =,1ki x =则: 1i j u u -≤-,1j k u u -≤-,1i k u u -≤-从而有: 03≤-,导致矛盾。 其它情况以此类推。 于是我们可以得到如下的模型:

人工智能实验报告:货郎担问题

人工智能实验报告 西安交通大学

实验一:货郎担问题 一、问题重述 假设有一个旅行商人要拜访n个城市,他必须选择所要走的路径,路经的限制是每个城市只能拜访一次,而且最后要回到原来出发的城市。路径的选择目标是要求得的路径路程为所有路径之中的最小值。 二、问题分析 如果只考虑贪心算法,由于在最后需要回到原来的出发点,很难得到最后的最有结果,所以需要全方面地考虑到各种情况。 本实验由于考虑的村庄的总数量不是很多,可以采取枚举算法。枚举所有的状况,进而做出比较,可得到全局的最优解。 三、程序设计 程序可以采用sort和work两个函数进行具体的计算,主函数主要用来编辑界面,使得最终的结果比较可视化。 首先,定义dis矩阵作为距离矩阵,定义way数组为路程记录。 对主函数的操作: 1.输出如下编辑的运行界面: cout<<" ================货郎担问题的解法================"<

送货路线设计问题分析03

送货路线设计问题分析 摘要 本文是关于送货员需要以最快的速度及时送达货物的问题,可看作是类货郎担问题。 第一问中,我们采用最近点插入模型,得到了30个货物的送货方案及路线时间,并且应用局部全排列穷举法将上面得到的路线进行优化,得到最终路线为: O->18->13->19->24->31->27->27->39->27->31->31->34->40->45->45->45->42 ->49->42->43->43->38->36->38->35->32->32->32->23->23->16->14->17->21->26->O,总用时为(包括交货时间):228.18分。 第二问中,根据时间优先的则,将所有货物送达点进行分块分组,即优先送达时间要求紧的货物,并且利用穷举法列举出每一块中货物送达点的任意排列顺序,求出其中耗时最短的路线即为所需结果,最终路线为: O->18->13->19->24->31->27->27->39->27->31->31->34->40->45->45->45->42 ->49->42->43->43->38->36->38->35->32->32->32->23->23->16->14->17->21->26->O,总用时为(包括交货时间):228.18分。 第三问中,由于货物重量和体积的限制,送货员需中途取货。我们采用最远点优先送货和最近点优先送货两种方案进行路线的分划,并根据最终求得结果的比较,得出前者方案更优,因此选用第一种方案送货。最终路线为: 第一趟:0->18->13->11->12->15->25->29->22->20->22->30->28->33->28->30 ->22->15->5->2->4->3->8->1->6->1->7->10->9->14->18->0, 第二趟:0->26->31->19->24->31->34->40->47->40->37->41->46->48->44->50 ->45->36->27->39->27->31->26->0 第三趟:0->21->17->23->16->23->32->35->38->43->42->49->42->43->38 ->36->21->0 第四趟:0->26->26->26->0 总时间为:394.3分。 关键字:快递公司送货货郎担问题最近邻点插入全排列穷举法 1 问题重述 在物流行业中,送货员需要以最快的速度及时将货物送达,而且他们往往一人送多个地方。

Tsp问题的几种算法的讲解

摘要 本文分析比较了tsp问题的动态规划算法,分支界限法,近似等算法。分析了旅行商问题的时间度特点,针对启发式算法求解旅行商问题中存在的一些问题提出了改进算法。此算法将群体分为若干小子集,并用启发式交叉算子,以较好利用父代个体的有效信息,达到快速收敛的效果,实验表明此算法能提高寻优速度,解得质量也有所提高。 关键词:旅行商问题TSP Abstract this paper analyzed the time complexity of traveling salesman problem,then put forward some imprivement towards the genetic algorithm for solving this problen: divding the population into some small parent individual well.so it can quickly get into convergence, the experimental result indicates the impwoved algorithm can accelerate the apeed of finding solution and improve the precision. Keywords traveling salesman problem; genetic algorithm; subset; henristic crossover operator

目录 1、摘要--------------------------------------------------------------1 2、Abstract---------------------------------------------------------1 3、Tsp问题的提法------------------------------------------------2 4、回溯法求Tsp问题--------------------------------------------3 5、分支限界法求Tsp问题--------------------------------------7 6、近似算法求解Tsp问题-------------------------------------10 7、动态规划算法解Tsp问题----------------------------------12

动态规划实现货郎担问题

#include #include using namespace std ; typedef list LISTINT; LISTINT listAnother; LISTINT list_result; int d[4][4]={{-1,10,15,20},{5,-1,9,10},{6,13,-1,12,},{8,8,9,-1}}; //路径权值int matrix_length=4; int getPath(int n,LISTINT list_org) { LISTINT::iterator i; int minValue; if(n==1) { i=list_org.begin(); minValue= d[*i-1][0]; if(list_org.size()==matrix_length-1) { list_result=list_org; } } else { int temp; i=list_org.begin(); temp=*i; list_org.erase(i); i=list_org.begin(); minValue=d[temp-1][*(i)-1]+getPath(n-1,list_org); if(list_org.size()==matrix_length-1) { list_result=list_org; } for(int j=2;j

{ i++; } int tempvalue=*i; list_org.erase(i); list_org.push_front(tempvalue); i=list_org.begin(); tempvalue=d[temp-1][*(i)-1]+getPath(n-1,list_org); if(tempvalue

阅读“乡村生活”《货郎担》完成素养测试题(后附答案)

阅读“乡村生活”《货郎担》完成素养测试题(后附答案) 货郎担 ①昔日的乡村热闹的事不多,货郎担一来,孩子们就像炸了锅,一个个揣着甜蜜的心思一下子围拢过来,宁静的村庄顿时卷起一层热浪。 ②货郎又叫货郎担,也叫挑货郎。那时的乡村,卖货人挑着箱子走村串巷,卖些针头线脑和小孩子好吃和好玩的小东西。这行当在上世纪70年代的乡村很惹眼,也很有趣。小孩子手里没有一分钱,但随便找些废铜烂铁、旧塑料或牙膏皮,就能换回几样自己想要的小甜食和小玩具。那时的日子里,隔上三两天,就会有货郎担走进村子,小村庄立马生动起来,最得意的是一群疯玩的小孩童。 ③挑货郎肩挑一个大箱子,另一头是一个大箩筐。大箱子上有一个玻璃罩,里面是一些家用小百货,火柴、发夹、小肥皂、松紧带、搓手油、顶针、小圆镜,还有逗小孩子吃和玩的小东西,最常见的有花生糖、麦芽糖、麻子糖、甜米团和红红绿绿很是诱人的小糖豆,再就是一吹就哇哇响的小喇叭。红色塑料小公鸡,也是娃娃们觉得最有趣的小玩具。挑货郎的大箩筐,盛满了从十村百户回收来的生活废物料,回去后换成钱,便可用来过日子了。 ④货郎担来到了村子,拨浪鼓雨点般响起来,先是“噔噔、噔噔”响两声,还来不及喘上一口气,又“当啷啷噔、当啷啷噔”地响上一大串。小孩子一个个心里直痒痒,挑货郎还没放稳扁担,便“轰”的一声围过去。 ⑤小时候拨浪鼓一响,我们村可真热闹了。全村的小孩子一个不少地都会跑过来。我先是对挑货郎的拨浪鼓感兴趣,它一边一个小耳锤,敲得人直抓心,充满了诱惑和甜蜜。我左瞧右看,真想上去摸几下,刚一伸手,就被挑货郎阻止了。挑货郎的大箱子真是一个百宝箱,里面果真有一个玩具拨浪鼓,红红的鼓面惹眼又诱人。我扭头就往家里跑,很快找来一大把废物料,连姑姑剪下来的一截头发也拿过来,我终于有了特好玩的拨浪鼓。同村的小朋友兴奋地围住挑货郎,眼珠子滴溜溜地盯上几眼大箱子,一转身就“咚咚咚”往家跑。这家那家的墙角和柜子,小孩童都翻了个遍,凡是能用来交换的东西都找了出来。有的用废铁块换回一个小喇叭,有的用旧塑料换回一个小皮球,还有的换回一小块麻子糖,一个个那高兴劲儿,真像喝了蜜。有一次我很想吃几个甜米团,玻璃罩下那一粒粒白色的小米花,被黄盈盈的糖浆粘成一个个小圆球,真是诱人,可家里找不到一点东西给货郎担去交换,于是我就心急地找母亲。母亲过日子节俭,一分钱也不舍得往外拿,嘴馋的我急坏了。这时爷爷走过来,二话没说就从衣兜里掏出一毛钱,我高兴得跳起来,心里不知有多轻快,这真是一件无法忘掉的事。

组合优化问题简介

在管理科学、计算机科学、分子物理学和生物学以及超大规模集成电路(VLSI)设计、代码设计、图象处理和电子工程等科技领域中,存在着大量组合优化问题。其中许多问题如货郎担问题、图着色问题、设备布局问题以及布线问题等,至今没有找到有效的多项式时间算法。这些问题巳被证明是NP 完全问题[1]。 用最优算法如线性规划求NP 完全间题的最优解,需要问题规模的指数阶时间,在问题规模增大时,往往由于计算时间的限制而丧失可行性。用近似算法如贪心法求解NP 完全问题,在多项式界的时间里,只能给出近似最优解。 本章介绍组合优化问题和计算复杂性理论的基本概念,并结合几个组合优化的NP 完全问题实例,介绍其近似算法。最后,在引人邻域结构概念的基础上,介绍一种通用的近似算法—局部搜索算法。 §1组合优化问题 组合优化问题的目标是从组合问题的可行解集中求出最优解。本书研究那些可以用数学语言精确描述的组合优化问题,并假定其可行解集是有限的或可数无限的,同时解的质量可以量化,因而可以比较不同解间的质量差异。 1.1组合优化问题的基本概念 优化问题有三个基本要素:变量、约束和目标函数。在求解过程中选定的基本参数称为变量,对变量取值的种种限制称为约束,表示可行方案衡量标准的函数称为目标函数。 货郎担问题(TSP)是组合优化中最为著名的问题,它易于陈述而难于求解。自1932年K. Menger 提出以来,已引起许多数学家的兴趣,但至今尚未找到有效的求解方法。由于货郎担问题综合了一大类组合优化问题的典型特征,下面以它为例说明组合优化间题的基本概念。 例1.1货郎担问题(TSP) 给定n 个城市和每两个城市间的距离。一个货郎自某一城市出发巡回售货,问这个货郎应该如何选择路线,使每个城市经过一次且仅一次,并且路径长度最短。 设[]ij D d =是距离矩阵,其元素ij d 表示城市j i ,间的距离。则对变量D 的约束是: (1)每个元素是非负整数,即 0,0,ij d i j n ≥≤≤; (2)对角线上的元素为0,即 0,0ii d i n =≤≤; (3)是对称矩阵,即 ,0,ji ij d d i j n =≤≤; (4)任愈三个元素满足三角不等式,即 ,0,,i j j k i k d d d i j k n +≥≤≤; TSP 的一个解可表述为一个循环排列()12,,n ππππ= ,它也可表示为 1231n πππππ→→→→→ . 的一条路径,()1i i n π≤≤是该路径中第i 个经过的城市。显然,满足i j ππ≠,若i j ≠的解才是可行解。所有可行解的集合构成解空间S ,即S={n 个城市的所有循环排列},解空间的规模为()1! 2 n S -=。路径长 度 ()1 ,1 i i n i f d πππ +==∑(约定11n ππ+=) 是货郎担问题的目标函数。TSP 的目标是使路径长度最短,即使目标函数()f π最小。 下面给出组合优化问题的定义。 定义1.1 组合优化问题是在给定的约束条件下,求目标函数最优值(最小值或最大值)的问题。组合优化问题的一个实例可以表示为一个对偶(S, f ),其中解空间S 为可行解集,目标函数f 是一个映射,定义为 :f S R →. 求目标函数最小值的问题称为最小化向题,记为 () m i n ,f i i S ∈; (1.1.1) 求目标函数最大值的同题称为最大化间题,记为

TSP问题的解决与实现讲解

1. 问题描述 所谓TSP问题是指旅行家要旅行n个城市,要求各个城市经历且仅经历一次,并且要求所走的路程最短。该问题又称为货郎担问题、邮递员问题、售货员问题,是图问题中最广为人知的问题。 2. 基本要求 (1) 上网查找TSP问题的应用实例; (2) 分析求TSP问题的全局最优解的时间复杂度; (3) 设计一个求近似解的算法; (4) 分析算法的时间复杂度。 3. 提交报告 课程设计报告提交内容包括: (1) 问题描述;(2) 需求分析;(3) 概要设计;(4) 详细设计;(5) 调试分析;(6) 使用说明;(7) 测试结果;(8) 附录(带注释的源程序)。 参见“数据结构课程设计概述.pdf”和“数据结构课程设计示例.pdf”。 指导教师(签字): 系主任(签字): 批准日期:2014年月日 1.问题描述 (1)题目要求 旅行家要旅行n个城市,要求各个城市经历且仅经历一次,最终要回到出发的城市,求出最短路径。 用图论的术语来说,假如有一个图G=(V,E),其中V是顶点集,E是边集,设D=(d )是由 ij 顶点i和顶点j之间的距离所组成的距离矩阵。TSP问题就是求出一条通过每个顶点且每个顶点只通过一次的具有最短距离的回路。

(2)基本要求 a. 上网查找TSP 问题的应用实例; b. 分析求TSP 问题的全局最优解的时间复杂度; c. 设计一个求近似解的算法; d. 分析算法的时间复杂度。 (3)测试数据 5个城市的TSP 问题: 注:由于矩阵所表示的是两个城市之间的距离,所以该矩阵为对称矩阵 路程矩阵如图所示: 最短路径为v 0v 1v 4v 2v 3 2.需求分析 (1)本程序用于求解n 个结点的最短哈密尔顿回路问题。 (2)程序运行后显示提示信息—“Please insert the number of cities:”,例如用户输入5,则表示结 点n 的值为5;接下来程序输出提示信息—“Please insert the distance between one city and another:”,例如用户输入测试数据中给出的路程矩阵,表示任意两个城市之间的距离,比如第一个城市到第0个城市之间的距离为25。 (3) 用户输入数据完毕,程序将输出运算结果。 (4)测试数据均为正数,其中用999来表示两个城市之间距离为∞。 3.概要设计 为了实现上述程序功能,使用优先队列来维护结点表,因此需要图和队列两个抽象数据类型。 0 1 2 3 4 0 1 2 3 4

相关文档
相关文档 最新文档