Instant Download MATLAB Optimization Toolbox User S Guide The Mathworks PDF All Chapters
Instant Download MATLAB Optimization Toolbox User S Guide The Mathworks PDF All Chapters
com
https://textbookfull.com/product/matlab-
optimization-toolbox-user-s-guide-the-mathworks/
https://textbookfull.com/product/matlab-global-optimization-toolbox-
user-s-guide-the-mathworks/
textbookfull.com
https://textbookfull.com/product/matlab-econometrics-toolbox-user-s-
guide-the-mathworks/
textbookfull.com
https://textbookfull.com/product/matlab-bioinformatics-toolbox-user-s-
guide-the-mathworks/
textbookfull.com
https://textbookfull.com/product/humanistic-psychology-current-trends-
and-future-prospects-richard-house/
textbookfull.com
Out of Eden: The Surprising Consequences of Polygamy 1st
Edition David P. Barash
https://textbookfull.com/product/out-of-eden-the-surprising-
consequences-of-polygamy-1st-edition-david-p-barash/
textbookfull.com
Home to You 1st Edition Lacey Black & Kaylee Ryan [Black
https://textbookfull.com/product/home-to-you-1st-edition-lacey-black-
kaylee-ryan-black/
textbookfull.com
https://textbookfull.com/product/further-advances-in-pragmatics-and-
philosophy-part-2-theories-and-applications-alessandro-capone/
textbookfull.com
https://textbookfull.com/product/netters-head-and-neck-anatomy-for-
dentistry-3-3rd-edition-neil-s-norton-phd/
textbookfull.com
https://textbookfull.com/product/strategy-an-international-
perspective-6th-ed-edition-bob-de-wit/
textbookfull.com
Optimization Toolbox™
User's Guide
R2020a
How to Contact MathWorks
Phone: 508-647-7000
Acknowledgments
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Getting Started
1
Optimization Toolbox Product Description . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
v
Setting Up an Optimization
2
Optimization Theory Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
vi Contents
Linear Equality Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-80
Examining Results
3
Current Point and Function Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
vii
Exit Message Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
viii Contents
Use a Sparse Solver or a Multiply Function . . . . . . . . . . . . . . . . . . . . . . 4-10
Use Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Optimization App
5
Optimization App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Optimization App Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Specifying Certain Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Importing and Exporting Your Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
ix
Minimization with Gradient and Hessian . . . . . . . . . . . . . . . . . . . . . . . . . 6-13
x Contents
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Code Generation in fmincon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114
What Is Code Generation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114
Code Generation Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114
Generated Code Not Multithreaded . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-115
Nonlinear Problem-Based
7
Rational Objective Function, Problem-Based . . . . . . . . . . . . . . . . . . . . . . . 7-2
xi
Multiobjective Algorithms and Examples
8
Multiobjective Optimization Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Multiobjective Optimization Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
xii Contents
Optimal Dispatch of Power Generators: Solver-Based . . . . . . . . . . . . . . . 9-55
Problem-Based Optimization
10
Problem-Based Optimization Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
xiii
Named Index for Optimization Variables . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
Create Named Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
Use Named Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21
View Solution with Index Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-22
Create Initial Point for Optimization with Named Index Variables . . . . 10-43
Quadratic Programming
11
Quadratic Programming Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
Quadratic Programming Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
interior-point-convex quadprog Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 11-2
trust-region-reflective quadprog Algorithm . . . . . . . . . . . . . . . . . . . . . . . 11-7
active-set quadprog Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11
xiv Contents
Step 1: Decide what part of H to pass to quadprog as the first argument.
.................................................... 11-17
Step 2: Write a function to compute Hessian-matrix products for H. . . . 11-17
Step 3: Call a quadratic minimization routine with a starting point. . . . 11-18
Preconditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-19
Least Squares
12
Least-Squares (Model Fitting) Algorithms . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Least Squares Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Linear Least Squares: Interior-Point or Active-Set . . . . . . . . . . . . . . . . . . 12-2
Trust-Region-Reflective Least Squares . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
Levenberg-Marquardt Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6
xv
Setting Up the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27
Systems of Equations
13
Equation Solving Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
Equation Solving Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
Trust-Region Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
Trust-Region-Dogleg Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
Levenberg-Marquardt Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5
fzero Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6
\ Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6
xvi Contents
Nonlinear Equations with Jacobian Sparsity Pattern . . . . . . . . . . . . . . . 13-13
Step 1: Write a file nlsf1a.m that computes the objective function values.
.................................................... 13-13
Step 2: Call the system of equations solve routine. . . . . . . . . . . . . . . . . 13-13
xvii
Optimization Options Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-6
Optimization Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-6
Hidden Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-16
Functions
16
xviii Contents
Acknowledgments
xix
Acknowledgments
Acknowledgments
MathWorks® would like to acknowledge the following contributors to Optimization Toolbox
algorithms.
Thomas F. Coleman researched and contributed algorithms for constrained and unconstrained
minimization, nonlinear least squares and curve fitting, constrained linear least squares, quadratic
programming, and nonlinear equations.
Yin Zhang researched and contributed the large-scale linear programming algorithm.
xx
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
1
Getting Started
Optimization Toolbox provides functions for finding parameters that minimize or maximize objectives
while satisfying constraints. The toolbox includes solvers for linear programming (LP), mixed-integer
linear programming (MILP), quadratic programming (QP), nonlinear programming (NLP),
constrained linear least squares, nonlinear least squares, and nonlinear equations. You can define
your optimization problem with functions and matrices or by specifying variable expressions that
reflect the underlying mathematics.
You can use the toolbox solvers to find optimal solutions to continuous and discrete problems,
perform tradeoff analyses, and incorporate optimization methods into algorithms and applications.
The toolbox lets you perform design optimization tasks, including parameter estimation, component
selection, and parameter tuning. It can be used to find optimal solutions in applications such as
portfolio optimization, resource allocation, and production planning and scheduling.
Key Features
• Nonlinear and multiobjective optimization of smooth constrained and unconstrained problems
• Solvers for nonlinear least squares, constrained linear least squares, data fitting, and nonlinear
equations
• Quadratic programming (QP) and linear programming (LP)
• Mixed-integer linear programming (MILP)
• Optimization modeling tools
• Graphical monitoring of optimization progress
• Gradient estimation acceleration (with Parallel Computing Toolbox™)
1-2
First Choose Problem-Based or Solver-Based Approach
This table summarizes the main differences between the two approaches.
Approaches Characteristics
“Problem-Based Optimization Setup” Easier to create and debug
Represents the objective and constraints symbolically
Requires translation from problem form to matrix form, resulting in a
time
Does not allow direct inclusion of gradient or Hessian; see “Include De
Problem-Based Workflow” on page 7-20
See the steps in “Problem-Based Optimization Workflow” on page 10-2
“Problem-Based Workflow for Solving Equations” on page 10-4
Basic linear example: “Mixed-Integer Linear Programming Basics: Pro
page 10-40 or the video Solve a Mixed-Integer Linear Programming Pr
Optimization Modeling
1-3
1 Getting Started
See Also
More About
• “Problem-Based Optimization Setup”
• “Solver-Based Optimization Problem Setup”
1-4
Solve a Constrained Nonlinear Problem, Problem-Based
This example shows how to solve a constrained nonlinear optimization problem using the problem-
based approach. The example demonstrates the typical work flow: create an objective function,
create constraints, solve the problem, and examine the results.
Note:
If your objective function or nonlinear constraints are not composed of elementary functions, you
must convert the nonlinear functions to optimization expressions using fcn2optimexpr. See the
last part of this example, Alternative Formulation Using fcn2optimexpr on page 1-0 , or “Convert
Nonlinear Function to Optimization Expression” on page 7-8.
For the solver-based approach to this problem, see “Solve a Constrained Nonlinear Problem, Solver-
Based” on page 1-11.
2 2
f (x) = 100 x2 − x12 + (1 − x1) ,
over the unit disk, meaning the disk of radius 1 centered at the origin. In other words, find x that
minimizes the function f (x) over the set x12 + x22 ≤ 1. This problem is a minimization of a nonlinear
function subject to a nonlinear constraint.
Rosenbrock's function is a standard test function in optimization. It has a unique minimum value of 0
attained at the point [1,1]. Finding the minimum is a challenge for some algorithms because the
function has a shallow minimum inside a deeply curved valley. The solution for this problem is not at
the point [1,1] because that point does not satisfy the constraint.
This figure shows two views of Rosenbrock's function in the unit disk. The vertical axis is log-scaled;
in other words, the plot shows log(1 + f (x)). Contour lines lie beneath the surface plot.
rosenbrock = @(x)100*(x(:,2) - x(:,1).^2).^2 + (1 - x(:,1)).^2; % Vectorized function
% Create subplot
subplot1 = subplot(1,2,1,'Parent',figure1);
view([124 34]);
grid('on');
hold on;
% Create surface
1-5
Random documents with unrelated
content Scribd suggests to you:
made much more interesting than they otherwise would be, by using
them in practical service whenever an opportunity occurs.
“But, although we want to be careful not to be vain or foolish
because we have had the privilege of doing such things as it is the
duty of every scout to do, when he gets a chance, we must
recognize good work when we see it, so as to encourage one
another to do more such work, and to do it better and better as time
goes on.”
He then turned and spoke in a low voice to Mr. Miller, who
immediately gave the command:
“Perkins—front and center!”
Jack immediately marched down and stood directly opposite the
Chairman.
“Perkins,” said the Chairman, “the Court of Honor, especially
convened to consider the work of the ship’s company at the Salem
fire, have decided that your work ashore was of excellent quality and
deserves the commendation of the Court. The Court commends you
for carrying out your instructions promptly and with good judgment.”
Jack saluted, and, at the word of command, marched back to his
regular position.
Malloy, Young, Ellsworth, and Smith were then ordered to “front and
center” and stood “at attention” before the Chairman.
“It gives me pleasure to tell you, boys,” said the Chairman, “that you
have been especially commended for good work at the Salem fire.”
All saluted, and at the words “About face—march”, from Mr. Miller,
returned to their positions with a grin upon their faces.
Then Tom was ordered forward, and received a commendation for
efficient first-aid work in helping to save a woman by stopping the
flow of blood from a severed artery. There was general surprise at
Tom’s first-aid commendation, for none of the boys knew about the
incident except Dick and Chippie.
“Just like him,” muttered Malloy; “with all his talk about Gray and the
cat, he hasn’t let on about himself at all!”
“Gray, front and center,” was the next command.
Dick took his position “at attention” before the Chairman, with the
most solemn face you could possibly imagine.
“Boys,” said the Chairman, addressing them all together, “the Court
finds that the case of Gray is somewhat different from the others
and requires special attention. Not only did he do good work in
helping in a rescue and in moving belongings to a place of safety,
but he actually saved life, although the life was only that of a little
animal,—a little girl’s pet. The regular medal for ‘life saving’ could
not be awarded in such a case, because that is reserved as a reward
for the saving of human life only; for, while the law recognizes the
sacredness of all harmless life, it makes an important distinction
between the value of human life and that of an animal. However, the
qualities of unselfishness and courage which Gray has shown in
saving a kitten from the third story of a burning house are qualities
which he or any other would need in saving human life under similar
circumstances.”
While the Chairman was saying these words, Mr. Miller was watching
Dick’s face attentively, for it was getting paler and paler, more and
more troubled.
“The Court, therefore,” resumed the Chairman, “not only
commends”—here the Chairman paused as he noticed the
expression on Dick’s face.
“What’s the matter, Gray?” he asked kindly, in a low voice.
“I—I—can’t take it!” muttered Dick. “Don’t ask me now. May I speak
to Mr. Miller for a minute?”
All this had been said in an undertone, and the whole company was
stirred by a feeling, partly of curiosity, and partly of discomfort. Mr.
Miller was standing within earshot, and the Chairman nodded to him.
Then Mr. Miller beckoned to Dick and led him down the ladder into
the cabin.
The boys were then ordered to remain “at ease”, and every one
looked at his neighbor as if to say:
“I wonder what is going to happen next?”
Presently Mr. Miller appeared on deck again and reported to the
Chairman in a low voice; and, in a few minutes more, he went back
to get Dick, and they both stood alongside the Chairman.
The general feeling of suspense by this time had grown extremely
acute, when the Chairman said:
“Boys, Gray has asked permission to say something to us all before
we go on with awarding the honors. I ask you to listen to him with
careful attention. His only object in talking to you now is to do his
full duty as a Boy Scout under very trying circumstances.”
Dick had had a good, frank talk with Mr. Miller in the cabin below,
and had cleared his mind of a weight that had been pressing down
on him for some time past, although he had not, until that morning,
faced the necessity for action with perfect clearness. He now had
determined to make a clean breast of the whole matter and to
accept his just penalty—whatever that might be—like a man.
“I want to say, fellows,” said he, “that the umpire was wrong in the
game at Hull, when he decided in my favor about second base. I
never touched it. I got around to third and then home without ever
having come within six inches of second base, except after I had
been fairly put out. I haven’t any excuse; I knew it was wrong, but I
did not know how wrong it was. I have done other things like that
before, and I thought they were smart. Now you know it, and maybe
I shall lose my scout badge. I have lost the right to wear it, anyway,
and you can see as well as I that I can’t accept any honor for what
happened at Salem.”
He then turned to the Chairman, who said with a very quiet voice:
“You may go below for the present, Gray.”
The Chairman, Mr. Miller, and Mr. Wentworth then consulted
together, and finally asked Jack Perkins to join them. The whole
company was impressed by the solemnity of the incident. The
Chairman explained to the boys that the question of awarding an
honor to Gray under the present circumstances must be
reconsidered in the light of his confession.
“But,” said he, “I can assure you of one thing: however wrong Gray
has been in the past, I respect him for his straight-forwardness to-
day. Let me warn you boys against treating this matter in any way
that might appear to be mean or disrespectful to a fellow scout. It
would be a base and brutal thing to treat lightly such humiliation as
this.”
Judging from the faces of the boys as they separated when they
were dismissed, it seemed as if the warning of the Chairman were
hardly necessary. They were all sorry for Dick and greatly surprised,
but owing to his frank and public confession, they had a feeling of
confidence that everything would turn out right in the end.
CHAPTER XII
Another Meeting of the Club
While the meeting of the Triangle Club was going on at the Grays’
farm, Mr. Wentworth went ashore with the yeoman,—Bob Brackett—
to meet a new boy who was to join the ship that afternoon.
As soon as they had arrived at the landing, however, they were
approached by a tall, elderly man who looked as if he had come
from the country, and had rather a small boy at his side in the Land
Scout uniform.
“My name is Jackson,” said he, addressing Mr. Wentworth, “and I
have brought my nephew, William Brown, for whom, I understand, a
berth has been reserved on the Bright Wing.”
“Yes, sir,” replied Mr. Wentworth cordially, “and I am very much
obliged to you for being on hand so promptly, for you have saved
me the trouble of looking you up at the hotel.”
After shaking hands, Mr. Wentworth turned to Brown with a friendly
nod, and then, facing Bob, he said:
“This boy with the mail bag, Brown, is our yeoman, and we shall
have to wait until he has been to the post office, before returning to
the ship. Do you think, Mr. Jackson, that your nephew would like to
go to the post office with the yeoman? It might be pleasant for him
to make friends with one of the crew before he goes aboard.”
Mr. Jackson assented, and Billy Brown saluted awkwardly by
throwing his arm out on one side and then bringing it up to the back
of his head. “He’s a queer duck,” thought Bob, but his meditations
were interrupted by Mr. Wentworth.
“You can go now, Yeoman, and be as quick as you can. Remember
you are on duty, and you have no other errand but to post the
outgoing and to fetch the incoming mail.”
Mr. Wentworth spoke with decision; but his tone was so friendly that
any boy would have felt inclined to obey him.
The two scouts went off together at a smart pace; and, as they
walked up the street, Mr. Wentworth noticed a great contrast in the
way they held themselves. The same thought seemed to have
entered Mr. Jackson’s mind.
“I’m in great hopes,” he said, “that the drill and discipline on the
Bright Wing may improve Billy’s physical condition. He is a studious
boy, but he does not get enough fun or activity out of doors.”
“I understand, sir,” said Mr. Wentworth; “he has an intelligent face
and a good bright eye, but his body isn’t well gathered together. He
seems to have a little stoop in the shoulders. For how long is he to
be on board, sir?”
“His berth is engaged for two weeks, but if there is room for him, he
might possibly stay longer.”
“Well,” said Mr. Wentworth, “a good deal can be done in two weeks
if a boy is intelligent and willing,—I mean in the way of a start. A
good brain and willing disposition are the best sort of help to a boy
for getting his body into shape; for, if he can get a strong idea of
physical balance into his mind, it will give him an interest in keeping
his body up to the mark. But, of course, he needs practice and
exercise, too. I understand, sir, that you are also coming on board?”
“Yes,” replied Mr. Jackson, “I’m going as far as Provincetown, and
then I shall have to take the train for home. I have not had a good
sail for many years, and am looking forward with great pleasure to
being on a Boy Scout ship.”
Mr. Wentworth was very glad of this opportunity to find out the
special needs of the new boy, and he looked forward particularly to
reporting everything he had learned to the Chairman and Mr. Miller.
“I shouldn’t wonder,” thought he to himself, “if we made a good
light-weight boxer of the lad before he leaves the ship; but the main
thing is to teach him to gather himself together and to swim and
row well.” He had a quick eye for such things.
The conversation had not continued much longer when Bob and Billy
reappeared with a heavy load of letters and bundles in the mail bag.
Fred Hamilton, the boatswain, was in charge of the launch that lay
alongside the landing. Mr. Wentworth ordered the boys into her
stern, and then got in himself to give Mr. Jackson a hand. He then
went forward to the wheel and the boatswain stood by the engine.
When they returned to the ship, it was recreation hour, and the
music of the “ship’s band” greeted the newcomers across the water.
Half a dozen hands were stretched over the side to catch the painter
of the launch as she approached the side ladder. The Chairman and
the Captain were standing on deck ready to welcome Mr. Jackson.
Bob immediately took the mail below and sorted it out according to
regulations, while Mr. Wentworth went to the clothes locker to find a
suit of “whites”, and a blue working suit to fit the new apprentice
seaman, William Brown.
Billy’s “Station Billet” was made out within half an hour from the
time he arrived, and Bob was detailed to explain it to him.
Billy made out that he was Number 6 in the Second Division, Second
Section, which was in charge of Harold French, as “B. M.”, and Bob
offered to take him to French so that he could report at once.
French looked him over quietly and then said, “You know how to
swim, I suppose?”
“Yes,” said Billy, “I’ve done my fifty yards.”
“How about diving?” asked French.
Billy put his hand on his stomach with a smile and said with a
peculiar drawl, “I’ve had a good many slaps right here. I’m not much
good at that.”
“Probably you don’t swim under water, then,” replied the “B. M.”
“No,” said Billy, “and we never went beyond our depth where I
learned swimming.”
“Well,” said French, “we’ll have to go with you under water the first
chance we get, and I guess we can teach you a thing or two.”
Billy answered these questions with a deliberate air and without any
evidence of being ill at ease. He evidently was in the habit of
thinking before he spoke, and carefully listening to what was said;
and, although his carriage was poor and his physique not particularly
strong, French liked the clear, steady look in his eyes.
As Billy was turning away, the “B. M.” called after him, “Say, young
fellow, have you put your things into your locker and got them in
order yet?”
“Yes,” replied Brown.
“Well,” said the “B. M.”, looking at his watch, “we’ve got twenty-five
minutes before prayers, and I guess we can go forward and have
ten minutes’ drill.”
Then he turned for a minute to Dick Gray who had just returned on
board, and said in an undertone: “You just keep an eye on him,
Dick, and show him the ropes.”
At that moment there happened to be nobody on the forward deck,
so that French and Billy and Dick had it all to themselves. French
gave his commands in a comparatively subdued voice, so as not to
attract a crowd, and then suggested to Brown a few simple ideas
about the attitude of respectful attention and the significance of it in
the daily life of a scout, while Dick took the position to illustrate
what French meant.
Billy was rather awkward, and his large round eyeglasses and
prominent ears gave him a queer look of somehow being out of
place in his new surroundings; but French noticed that he seemed to
enjoy the drill and to take a genuine interest in what he was being
taught.
“Heels together, little finger on the seam of your trousers, chest up,
stomach in,—don’t bend backwards, balance on the instep—neck
straight, chin in. There, sonny, that’s the way you want to hold
yourself at quarters, or any time ‘at attention.’ But you can’t expect
to do it easily without teaching your body to be strong in the right
places. You seem kind of soft now, and here’s a little medicine that
will help harden you a bit.”
Then he and Dick showed him an exercise in deep breathing and
stretching. “Do that six times, two or three times a day, and I guess
it will give you a lift,” said French.
Billy thought of thanking French, but somehow or other felt that his
gratitude would not be appreciated,—or else that he had better
show it by making progress rather than by words,—so he drew
himself up straight and waited to see what was going to happen
next. Just then the boatswain’s call sounded out sharp for prayers,
and they all went down the companionway to the berth deck.
Billy’s locker and bunk were not far from Dick’s, and after “tattoo”
they undressed together and talked about a number of things that
had aroused Billy’s curiosity. They were interrupted by the sounding
of “taps”; and a minute after Bertie Young, the master-at-arms,
made his rounds to see that all were in their bunks and that
everything was quiet.
“He knows mighty little about a vessel,” thought Dick, as he turned
over in his bunk, “but he’s a great one for asking questions, and I
shouldn’t wonder if he knew the whole thing before long.”
In the next bunk but one, Billy lay thinking about the farm and the
home folks. “I wonder,” thought he, “whether Roger has
remembered the special feed for the calf.” Then, in another minute,
he was thinking of the ship again, and of his present surroundings,
and wondered how he could have come into so entirely different a
world within only fifty miles of the world he had left behind him.
“There are lots of things on board this ship,” thought he, “that I
never heard of in my life; but I’ll do my best to learn every one of
them, and won’t the boys at home be surprised!”
CHAPTER XIV
The Key of the Keelson
The next morning Billy Brown went through “washing clothes” and
“scrubbing decks”, “colors”, “bright work”, “quarters”, and “mast”
with his eyes and ears wide open; and, all the time, he was looking
out for an opportunity to practice the exercise which his “B. M.” had
given him as medicine for his “softness.” During morning instruction
he had “knots and splices” for one period, “boxing the compass” for
another, and “ship’s tackle” with the mate for the third. He came out
very well with the first two, but was of course quite ignorant when it
came to ship’s tackle. As was always the case, however, the more
ignorant he was, the more anxious he seemed to learn, and quite a
shower of questions fell about the ears of the mate before the
instruction period was over.
While drill was going on among the boys, the Captain and the
Chairman were making a regular inspection below to prepare for the
visit of the Commandant of the Portsmouth Navy Yard, who was
expected on board at 11:30 to inspect the ship and crew.
Several boys’ lockers were found in disorder and reported to their
respective “B. M.’s.” But the Chairman was delighted with the
excellent condition of the galley and the forecastle.
“Ketchy”, the cook’s assistant, also served as cabin boy on board,
and he was particularly careful that morning to see that the officers’
quarters were as well up to the mark, at least, as any other part of
the vessel.
At half-past ten Mr. Miller left in the launch to call for the
Commandant at the Navy Yard; and Dick Gray, who was one of the
regular watch, was detailed to keep a sharp lookout for the return of
the launch and report it at once to Mr. Wentworth, who was Officer
of the Day.
All the boys were in their “whites” in honor of the impending visit;
and they were just about finishing the third instruction period when
Dick noticed the launch, flying the “Jack” in her bow, turn the corner
of the fort at the entrance of Little Harbor. He immediately reported
to Mr. Wentworth, and the “B. M.” on watch blew his call and
sounded “Retreat from drill.”
“Side boys—stand by!” was the next command, and two “B. M.’s”
with their respective quartermasters took their positions at the
starboard side-ladder. Meantime the rest of the crew was ordered to
its regular stations as at “quarters”, and only the watch were left to
lend a hand as the launch drew up to the side.
The Commandant was rather a stout officer with a pleasant look. A
good-humored smile lit up his face as he stepped on deck between
the side boys standing at salute and noticed the trill of the
boatswain’s call. His hand was first raised to acknowledge the salute,
and he then shook hands with the Captain and the Chairman who
were waiting to receive him.
They introduced Mr. Jackson as their guest, and all three walked aft
to the quarter-deck and sat down under the awning.
The boys were then ordered to “stand at ease” until after the
inspection of the ship, and their visitor inspected her carefully from
stem to stern, looking into every corner, and asking to have the lid
removed from everything that was covered up.
While they were in the galley he examined carefully the back of the
range to see whether there was any danger from fire; and then,
pointing to a ring in the deck beneath their feet, “What’s that?”
asked he.
“A coal bunker,” answered the Captain; and, lifting the corner, which
was a little stiff, he showed the place between the deck and the
timbers below where the range coal was kept.
The Commandant then asked questions about the storage of
gasoline for the launch and where the kerosene for the lamps was
kept. It was explained to him that the only supply of gasoline was